2 ms·
It's just better form. Also, if `i` is a struct with an overloaded postinc operator, it can be more expensive.
by WalterBright 7y ago
It's just better form. Also, if `i` is a struct with an overloaded postinc operator, it can be more expensive.
- jstimpfle 7y agoI think that is arguable. The form "array[idx++] = foo;" has undeniable elegance, and I still use it sometimes, even though I've developped a pretty verbose coding style in general.
- chopin 7y agoYeah, but why is it better form (I am coming from Java where it shouldn't make any difference)?
- WalterBright 7y agoIt's better form to not ask for a characteristic that you don't need. For example: 1. increment x 2. take the value of x, then increment x (1) is better form if you don't need the value of x.
- chopin 7y agoI just checked in Java, it is: 1. increment x, then take the value of x 2. take the value of x, then increment x Both are expressions in Java returning a value. My C is very rusty but I remember it being the same in C.