Problem with pointers
I have this small problem.
Have to 3 dimensional arrays:
int test1, test2;
In a for loop, I test a condition, and work on one of them. There are many iterations in the for loop.
Instead of writing an if-else condition and two seperate codes inside the if-else, I want to have a pointer that points to one of them so that I can use the same code for working on the array.
To do that, I declare a pointer: int *ptest;
and I do as assignment: ptest = &test1;
when I use ptest[i][j][k], I get a compile time error saying variable is neither an array or pointer.
Any idea, how I can make this work.
Re: Problem with pointers
I got it working. I was a single level pointer. I had to use ptest[i*m+j*n+k] to make it work.
|All times are GMT +5.5. The time now is 07:34.|