CODE UPDATED BASED ON ANSWERS BELOW AND WARNINGS/ISSUES REFLECTED
I am trying to code an array of pointers in C. A loop sets the values and another loop retrieves them - fairly straight forward. Here's how I am trying to set those values:
static int *toInvert[8];
for (i=0; i<8; i++)
{
int *intrplated = //Function call that returns int*
toInvert[i] = intrplated;
//printf("OL Value = %d\n\n\n\n\n",oLoop);
}
And to retrieve the values, here's the code without the loop, i.e., retrieves a fixed value:
int *tmpPtr = toInvert[3];
printf( "*(TPointer + %d) : %d\n\n", 3, *(toInvert[3] + 1)); //Still gives the recently added value
What happens is when I try to print the values, only the last added values in the setter loop gets printed. Even if I change tmpPtr to toInvert[1], it will still get the last set values.
But if I run the same code within the written for loop, it works as expected.
I need to know how to retrieve all the values that have been set. Thanks
EDIT
What I want is an array of 8 elements that contain 8 pointers. Each pointer in turn points to an array of 3 plain integers.
The array that I want should be like [p1][p2]...[p8] where [p1] points to an array of ints.