Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 15-10-2009
Member
 
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
Reply With Quote
  #2  
Old 15-10-2009
Member
 
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.
Reply With Quote
  #3  
Old 15-10-2009
Member
 
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" );
      }
Reply With Quote
  #4  
Old 15-10-2009
Member
 
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; }
            }
          }
        }
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Problems with a 2D array"
Thread Thread Starter Forum Replies Last Post
Array of array in PHP cyber-noob Software Development 4 26-02-2010 05:13 PM
C# array help Daren Software Development 5 03-01-2010 07:12 AM
Assigning an array to an array MACE Software Development 3 18-11-2009 05:19 PM
Array problems in java NetworkeR Software Development 2 06-11-2009 02:36 PM
XML to ARRAY Vandam Software Development 3 29-06-2009 06:14 PM


All times are GMT +5.5. The time now is 02:31 PM.