#post vs pre inc/decr
7 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
likely it's just about phrasing the same logic differently
if you use the resulting value
for example:
for(int i = N; --i;)
vs
for(int i = N - 1; i; i -= 1)
just about the same, but using pre-increment could ease things
Basically a short hand for if you want to do
/* int y = ++x; */
x += 1
int y = x;
or
/* int y = x++; */
int y = x;
x += 1
the difference is relevant if you do arr[x++] or arr[++x]
many people would say doing either of those is a bad idea and is bugprone, but that would be the most common example ime