Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   printing double array (http://www.go4expert.com/forums/printing-double-array-t665/)

musicmancanora4 28Mar2006 14:33

printing double array
 
Hi guys inside the double array it holds '?' character.

How would i do the format printing to print it like this

ithe user input variable is the size variable
if 5 is typed in it suppose to print 5 rows and columns and print 2 rows and columns if i entered 2.

for example
user inputs 2


+---+---+
| '?' | '?' |
+---+---+
| '?' | '?' |
+---+---+

it has to print the grid like this and im havin trouble with the formatting


Code:

void printGridMineSize(char displayGrid[MAX_GRID][MAX_GRID], unsigned size, int getMineSize)
{
    int i=0;
    int k=0;
    int j=0;
   
 
    printf("-------------------\n");
   
    for(i=0; i<size; i++)
    {
       
        for(k=0; k<size; k++)
        {
         
          printf("%c",displayGrid[i][k]);
         
       
         
       
        }
        /*printf("  %c    \n",displayGrid[i][k]); */
         
        printf("\n");
 
    }
   
    for(j=0; j<size; j++)
    {
    printf("+---+");
    }
    printf("\n");
}


coderzone 29Mar2006 07:21

Re: printing double array
 
Here is the solution for your prob

Code: C

for(int i=0; i < size; i++)
{
    for(int j=0; j < size; j++)
    {
        printf("+");
        printf("---");
    }
    printf("+\n");
    for(j=0; j < size; j++)
    {
        printf("| ");
        printf("? ");
    }
    printf("|\n");
    for(j=0; j < size; j++)
    {
        printf("+");
        printf("---");
    }
    printf("+\n");
}


musicmancanora4 29Mar2006 18:19

Re: printing double array
 
thnxs buddy i got it

coderzone 29Mar2006 20:13

Re: printing double array
 
Quote:

Originally Posted by musicmancanora4
thnxs buddy i got it

My pleasure


All times are GMT +5.5. The time now is 05:45.