I saw your question recently.
Well, basically pointer is just variable that changes it own value to position to "point" at some value.
For example we have one array made of 5 numbers. Out job is to decrease every number here by 1.
If array[5] = {1, 4, 7, 9, 2} we need our pointer to go from first to last number in array. We are going to do that like this:
array example[5] = {1, 4, 7, 9, 2}; //this is our example array
int i; //Here we need variable(for example variable "i" because its most frequently used) to be our pointer. He will "move" from first to last by increasing himself.
void loop { //this is loop that repeats forever
if(i < 5) { //Here we make condition for our pointer "i" position, if our pointer "i" is smaller than max count of numbers in our array(in this example five numbers). Instead of using if, we can use logic's like for, while or any other if you understand it.
array[ i ] = array[ i ] - 1; //here we subtract number one from position in our array. For example, if pointer position is 2 then we subtract number 1 from number that is at 2nd place in our array and that is number 4
i++; //We add 1 to pointer i because we want to move it for one position up. For example, if last time pointer was at position 3, that is number 7 in our array, now he will go and subtract 1 from next number, number 9 and so on.
}
if (i = 5) { //here we set condition for moment when pointer i will be equal to number 5, in the other words when our pointer is at last number. In our example, it's number 5.
i = 0; //here we reset our pointer i to value of 0 because we need him to start again from beginning, from position 0, so we can again increase from minimal to maximum position
}
}
With this example, you have code that will turn array that include numbers {1, 4, 7, 9, 2} to array that include {0, 3, 6, 8, 1}.
I hope this is useful and that it will help you our. If you are using instagram, i would be really grateful if you respond there at profile named @filikapec
Best Regards,
Filip Filipović.