Results 1 to 4 of 4

Thread: Problems with a 2D array

  1. #1
    Join Date
    Feb 2009
    Posts
    78

    Problems with a 2D array

    Hello

    I am facing some issue with the 2-dimensional arrays. My table is defined as such:

    Code:
    int grill[81][13];
    Over here i have 3 features that make transactions on that table. The first two runs properly. If any of the 3 functions the table structure is changed and the values are loaded into this table in the main () function. Not understanding where it comes from, I investigated with GDB.

    I grill is at 0x7fff41d2b428; grill [cell] (cell = 0) at 0x7fff41d2b7e0 and grill [cell] [0] at 0x100000001

  2. #2
    Join Date
    Oct 2008
    Posts
    137

    Re: Problems with a 2D array

    Sure i will help you out with this before that may i know programming language are you using it and can you provide me your code so that i will come to know where are you making mistake.

  3. #3
    Join Date
    Feb 2009
    Posts
    78

    Problems with a 2D array

    I am using C as my programming language and following are the code for the same and i am not able to understand that if I posted up my grid line before everything worked, and the line after that bug. There's no reason

    Code:
    printGrill(grill); / / then it works
    if(grill[cell][3]==1) / / then it works more
    Code:
    void printGrill(int grill[][13])
          {
           int i, j, k;
           printf("-------------------------------------\n" );
           k=0;
           for(i=0;i<9;i++)
    {
     for(j=0;j<9;j++)
      {
       switch(grill[k][3])
        {
         case 0 : printf("| 0 " ); break;
         case 1 : printf("| %d ", grill[k][4]); break;
        }
       k++;
      }
     printf("|\n-------------------------------------\n" );
    }
           printf("\n\n\n" );
          }

  4. #4
    Join Date
    Oct 2008
    Posts
    137

    Issue with a 2D array

    [QUOTE=Preetish;4652629]
    if(grill[cell][3]==1) / / then it works more[/CODE]

    [QUOTE]

    You try to do anything there? If yes, do not code for that line.

    And try to use see the following code i am sure this will help you a lot.

    Code:
    for(zone_type=0;zone_type<3;zone_type++)
    {
     for(zone=0;zone<9;zone++)
      {
       for(cell=0;cell<81;cell++)
        {
                 printGrill(grill);
                 if(grill[cell][3]==1) { continue; }
                }
              }
            }

Similar Threads

  1. Array of array in PHP
    By cyber-noob in forum Software Development
    Replies: 4
    Last Post: 26-02-2010, 05:13 PM
  2. C# array help
    By Daren in forum Software Development
    Replies: 5
    Last Post: 03-01-2010, 07:12 AM
  3. Assigning an array to an array
    By MACE in forum Software Development
    Replies: 3
    Last Post: 18-11-2009, 05:19 PM
  4. Array problems in java
    By NetworkeR in forum Software Development
    Replies: 2
    Last Post: 06-11-2009, 02:36 PM
  5. XML to ARRAY
    By Vandam in forum Software Development
    Replies: 3
    Last Post: 29-06-2009, 06:14 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,705,404.23132 seconds with 17 queries