I have a brain cramp and I need some help.
I have a chunk of code below which demonstrates
a problem I have with multidimensiona l arrays.
I want to keep it simple but something specific is getting in the way.
int a[10][10];
int b[10][10];
int **present;
int **next;
// Sorry I left these two lines out.
present=a;
next=b;
bool done=false;
while(!done)
{
// Loop which substitutes for complex calculation
for(int i=0;i<10;i++)
for(int j=0;j<10;j++)
next[i][j]=present[i][j];
int **temp=next;
next=present;
present=temp;
test_for_done(p resent);
}
Compare this to the one-dim version ( which works )
int a[10];
int b[10];
int *present;
int *next;
present=a;
next=b;
bool done=false;
while(!done)
{
// Loop which substitutes for complex calculation
for(int i=0;i<10;i++)
next[i]=present[i];
int *temp=next;
next=present;
present=temp;
test_for_done(p resent);
}
The reply-to email address is olczyk2002@yaho o.com.
This is an address I ignore.
To reply via email, remove 2002 and change yahoo to
interaccess,
**
Thaddeus L. Olczyk, PhD
There is a difference between
*thinking* you know something,
and *knowing* you know something.
I have a chunk of code below which demonstrates
a problem I have with multidimensiona l arrays.
I want to keep it simple but something specific is getting in the way.
int a[10][10];
int b[10][10];
int **present;
int **next;
// Sorry I left these two lines out.
present=a;
next=b;
bool done=false;
while(!done)
{
// Loop which substitutes for complex calculation
for(int i=0;i<10;i++)
for(int j=0;j<10;j++)
next[i][j]=present[i][j];
int **temp=next;
next=present;
present=temp;
test_for_done(p resent);
}
Compare this to the one-dim version ( which works )
int a[10];
int b[10];
int *present;
int *next;
present=a;
next=b;
bool done=false;
while(!done)
{
// Loop which substitutes for complex calculation
for(int i=0;i<10;i++)
next[i]=present[i];
int *temp=next;
next=present;
present=temp;
test_for_done(p resent);
}
The reply-to email address is olczyk2002@yaho o.com.
This is an address I ignore.
To reply via email, remove 2002 and change yahoo to
interaccess,
**
Thaddeus L. Olczyk, PhD
There is a difference between
*thinking* you know something,
and *knowing* you know something.
Comment