3 ms·
int arr[5]; int i = 0; while (shouldIKeepGoing() && i < 5) arr[i++] = getAThing(); If you use ++i there you'll skip 0 and overflow the array. This is w
by stormbrew 11y ago
int arr[5];
int i = 0;
while (shouldIKeepGoing() && i < 5) arr[i++] = getAThing();
If you use ++i there you'll skip 0 and overflow the array. This is what the postfix form is for, if you value terseness.
Edit: To clarify, I'm not necessarily saying you don't know that's what it's for, but this is a pattern I see pretty frequently in the wild so I'm just throwing it out there with an explanation of why people find value in it.