3 ms·
The reasonable places you can use `++` and `--` in C are exclusively: - In a bare expression, with only the variable: `i++;` (That's what usually goes into `fo
by marcosdumay 10y ago
The reasonable places you can use `++` and `--` in C are exclusively:
- In a bare expression, with only the variable: `i++;` (That's what usually goes into `for`.)
- In a simple assignment, without any extra expression: `int a = b++;`
- While updating an array index that appears nowhere else: `v[i++] = 0;`
Using it anywhere else is asking for trouble. In C++, using the last one is also asking for trouble.
- syncsynchalt 10y agoThe deeper you get into C++ the more you realize that Swift made the right call by removing all four inc/dec operators.
- marcosdumay 10y agoIn-place manipulation of values is a troublemaker. C is too old for its creators to know that, given that it's the language where people got to learn that. But no newer language should carry them.