Found the bug!
ok guys! We certainly missed this one! After I eliminated the return sentence I still couldn''t get the program to display the map in the correct way. After a little nap, though, I got it: the right way to pass the data from the sequential array to the two dimensional one is the following:
for(int j=0; j<60; j++)
for(int i=0; i<144; i++)
iMap[j]=buffer[i+(j*144)];
Yes, I know! Rediculous error. But what the hell. I''ve accepted the fact that I am no genious long time ago! Thanks for your time to reply, anyway.
: Problem updating a two dimensional array
Is it just me, or will this not work.
for(int j=0; j<60; j++) // it counts to 59
for(int i=0; i<144; i++) // it counts to 143
iMap[j]=buffer[i+(j*144)]; // assigns 143 + 59*144 to iMap[59]
Shouldn't it be:
for(int j=0; j<60; j++)
{
for(int i=0; i<144; i++)
iMap[j]=buffer[i+(j*144)];
}
Wouldn't this be the way to update each element?
Edited by - grandmlee on January 22, 2002 6:58:27 AM
for(int j=0; j<60; j++) // it counts to 59
for(int i=0; i<144; i++) // it counts to 143
iMap[j]=buffer[i+(j*144)]; // assigns 143 + 59*144 to iMap[59]
Shouldn't it be:
for(int j=0; j<60; j++)
{
for(int i=0; i<144; i++)
iMap[j]=buffer[i+(j*144)];
}
Wouldn't this be the way to update each element?
Edited by - grandmlee on January 22, 2002 6:58:27 AM
If at first you don't succeed, use profanity and try, try again.
quote: Original post by GrandMLee
Is it just me, or will this not work.for(int j=0; j<60; j++) // it counts to 59for(int i=0; i<144; i++) // it counts to 143iMap[i][j]=buffer[i+(j*144)]; // assigns 143 + 59*144 to iMap[59]
Shouldn''t it be:
for(int j=0; j<60; j++) { for(int i=0; i<144; i++) iMap[i][j]=buffer[i+(j*144)]; }
Wouldn''t this be the way to update each element?
No, both of them are identical
This
for(int x=0; x<3; x++) for(int y=0; y<3; y++) for(int z=0; z<3; z++) function(x,y,z);
is the same as this
for(int x=0; x<3; x++){ for(int y=0; y<3; y++) { for(int z=0; z<3; z++) { function(x,y,z); } }}
This is because a for statement treats the next line as a set of parentheses. This is the same as a while
you can do this for example
for(int x=0; x<3; x++);
or this
for(int x=0; x<3; x++){}
and they will both just make x count to 3.
Beer - the love catalyst
good ol'' homepage
Beer - the love catalystgood ol' homepage
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement