This is a follow on question to an earlier one.
I have learned some errors of my ways, but have extra questions. My objective is to have a local array in one method changed from another method without the use of any global variables.
void methodOne(){
int myArray[10] = {0};
int *pMyArray = myArray;
methodTwo(&*pMyArray);
}
This should be declaring an array of null values and passing a reference to the second array as I was shown how to do so correctly here.
void methodTwo(int *passedPointer){
int *localPointer = passedPointer;
}
Next I'd like to change the values of myArray from methodTwo. So to change the first [0] element I would say:
*localPointer = 1;
Is this correct?
Then to change the next element would I increment the pointer using:
localPoint++;
*localPointer = 2;
Would this change the second value in myArray? I'm not sure thats the correct way to do it is it?
TIA
localPointer[i].