Thread: how to print an array like in this picture..

  1. #16
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    i noticed the problem in this code
    insited the board it creates double "||" instead of one "|"
    how to fix it so every wal will be "|"
    Code:
    void printBoard(char board[N][N],int size){
    int index,kndex;
     for(index=0;index<size;index++)
    {
         for(kndex=0;kndex<size;kndex++)
        {
             printf("+-+");
    
         }
         printf("\n");
         for(kndex=0;kndex<size;kndex++)
        {
             printf("|%c|",board[index][kndex]);
         }
         printf("\n");
    
     }
      for(kndex=0;kndex<size;kndex++)
       {
             printf("+-+");
    
         }
    }

  2. #17
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > how to fix it so every wal will be "|"
    Jeez, how hard can it be to delete one of the | you're printing???
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #18
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    there is a double wall inside the board i need only one "|"

    http://img261.imageshack.us/img261/5066/42964910uf4.gif

    i tried to change the printf but it makes a total mess
    Last edited by transgalactic2; 01-03-2009 at 07:27 AM.

  4. #19
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    this what happens when i remove one "|"
    http://img237.imageshack.us/img237/8882/11479923wg0.gif

    ??
    Code:
    void printBoard(char board[N][N],int size)
    {
        int index,kndex;
        for(index=0;index<size;index++)
        {
           for(kndex=0;kndex<size;kndex++)
           {
               printf("+-+");
           }
           printf("\n");
           for(kndex=0;kndex<size;kndex++)
           {
               printf("|%c",board[index][kndex]);
           }
           printf("\n");
    
     }
    	
      for(kndex=0;kndex<size;kndex++)
      {
             printf("+-+");
    
      }
      
      printf("\n");
    }

  5. #20

  6. #21
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    i solved it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. Print Array in reverse order
    By swgh in forum C++ Programming
    Replies: 6
    Last Post: 11-06-2007, 01:41 PM
  3. i want to print a array
    By timhxf in forum C Programming
    Replies: 2
    Last Post: 01-07-2007, 04:25 AM
  4. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM