printing double array formatting trouble

Reply

Join Date: Mar 2006
Posts: 28
Reputation: musicmancanora4 is an unknown quantity at this point 
Solved Threads: 0
musicmancanora4 musicmancanora4 is offline Offline
Light Poster

printing double array formatting trouble

 
0
  #1
Mar 28th, 2006
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



  1. void printGridMineSize(char displayGrid[MAX_GRID][MAX_GRID], unsigned size, int getMineSize)
  2. {
  3. int i=0;
  4. int k=0;
  5. int j=0;
  6.  
  7.  
  8. printf("-------------------\n");
  9.  
  10. for(i=0; i<size; i++)
  11. {
  12.  
  13. for(k=0; k<size; k++)
  14. {
  15.  
  16. printf("%c",displayGrid[i][k]);
  17.  
  18.  
  19.  
  20.  
  21. }
  22. /*printf(" %c \n",displayGrid[i][k]); */
  23.  
  24. printf("\n");
  25.  
  26. }
  27.  
  28. for(j=0; j<size; j++)
  29. {
  30. printf("+---+");
  31. }
  32. printf("\n");
  33. }
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 126
Reputation: Vinoth is an unknown quantity at this point 
Solved Threads: 2
Vinoth Vinoth is offline Offline
Junior Poster

Re: printing double array formatting trouble

 
0
  #2
Mar 28th, 2006
Buffer size is too much , reduce it
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,567
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 707
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: printing double array formatting trouble

 
0
  #3
Mar 28th, 2006
>it has to print the grid like this and im havin trouble with the formatting
Do you need to print the grid as well as the array contents? If so, it takes a smidge more work.
  1. for ( i = 0; i < limit; i++ ) {
  2. /* Print a grid line */
  3. for ( j = 0; j < limit; j++ )
  4. printf ( "+---" );
  5. printf ( "+\n|" );
  6.  
  7. /* Print the row */
  8. for ( j = 0; j < limit; j++ )
  9. printf ( "'%c'|", grid[i][j] );
  10. putchar ( '\n' );
  11. }
  12.  
  13. /* Print the last grid line */
  14. for ( j = 0; j < limit; j++ )
  15. printf ( "+---" );
  16. printf ( "+\n|" );
>Buffer size is too much , reduce it
That's a rather useless comment. Elaborate, or don't bother posting.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC