6
votes
Accepted
what is wrong with using `*ptr = *ptr++;` in a loop?
*ptr = *ptr + 1;
and
*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.
...
4
votes
Accepted
What is the difference between ++i and i++?
x++ - Post-increment operator
++x - Pre-increment operator
In short,
x++ - x is incremented after the current statement is evaluated.
++x - x is incremented before the current statement is evaluated.
...
4
votes
Accepted
Trouble incrementing the number in jpeg filenames
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 ...
2
votes
what is wrong with using `*ptr = *ptr++;` in a loop?
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 ...
1
vote
Trouble incrementing the number in jpeg filenames
Sounds like you are declaring the counter as int counter = 0; each time around the loop.
If that's the case, make sure you only declare it once, outside the loop!
Only top scored, non community-wiki answers of a minimum length are eligible