Hi, I'm just wondering if this is the correct way to pass a pointer in a for loop:
say I have the following variables. (don't worry about functions not having prototypes etc, this is only an example).
Code:
#include <stdio.h>
int *firstPointer;
int *secondPointer;
int x = 0;
int array[5];
int aFunctionCall();
int main()
{
firstPointer = &x; // firstPointer now points to x, x holds the value 0.
aFunctionCall();
if (x == 2)
{
array[(*firstPointer)-1] = 5; // basically says 'array[2-1] = 5'; aka 'array[1] = 5'
}
int aFunctionCall()
for (*firstPointer=1; *firstPointer <= 3; *firstPointer++) // sets the value of x to 1 etc?
{
if (*firstPointer == 2) // basically saying if the value of x is 2?
{
return 0;
}
}
So basically at the end of this program array[1] will be holding the value 5, if i'm correct :P
so yeah, hope i didn't confuse everyone too much -_- thanks.