[–] TheBuddha 0 points 1 point 1 point (+1|-0) ago
https://softwareengineering.stackexchange.com/questions/223313/style-guide-for-c
However, it's more important to be consistent. Whatever you go with, be consistent.
[–] WhiteMakesRight 1 point -1 points 0 points (+0|-1) ago
Consistency is irrelevant when you're talking about two different operators with different semantics though. Use the one you actually need.
[–] theNakedNecromancer 0 points 2 points 2 points (+2|-0) ago
As long as you're not screwing with the way C performs the action, I don't see why not. In other words: x++ and ++x are two completely different functions.
So, doing x *= ++i will perform:
x = x * (i + 1)
But, doing x *= i++ will act like:
x = (x * i) + 1
Beyond that, style is up to you. Most C-coders (and style guides) won't want whitespace around the variable, or between a variable and increment operator. But, if it's code just for you, who cares?
[–] Rakosman 0 points 1 point 1 point (+1|-0) ago
I prefer to always use the postfix operator. To me it is more important to have easy to read code than succinct code, and I also think the prefix one is uglier, so there's that.
[–] WhiteMakesRight ago
But they're different operators, with different semantics......
[–] Rakosman 1 point -1 points 0 points (+0|-1) ago
Yes, and?