*ptr = *ptr + 1;
*ptr = *ptr++;
are different in the since that the first dereferences the location pointed to by ptr adds 1 to the value in there and stores the result back in that location.
the second dereferences the location pointed to by ptr, stores the value in there in the same location (which is actually kinda pointless but that's not the ...
x++ - Post-increment operator
++x - Pre-increment operator
x++ - x is incremented after the current statement is evaluated.
++x - x is incremented before the current statement is evaluated.
Well, lets say we have a function called foo which has a local variable x:
int x = 0;
In this function, x is ...
The problem turned out to be a memory allocation issue. I had declared another variable with too small an array size right before I declared my counter variable, so the first variable started running over into the second variable. Increasing the size of the first variable fixed the problem.
Just in case there's unclarity about the increment operator(s).
In C, the increment operators actually increment the value without the need to assign it to anything. The original value is incremented even though the old value (or the new one, in case of the prefix increment operator, ++i) is returned.
So if we have
int i = 0;
i++; // evaluates to 0, ...