Sitting here writing some code on a parser, so while writing a counter I needed to write something like
if ... {
...
some_list.clear();
counter++;
continue;
}
But, do you think writing it this sort of way is nicer,
...
++ counter; // With a space after operator
continue;
}
The thought was, maybe if you have some code around this, it'll stand out more... I don't know. What do you think?
Suppose I should also get some design practises book along with the other two books I am getting next week.
view the rest of the comments →
[–] 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++xare two completely different functions.So, doing
x *= ++iwill perform:But, doing
x *= i++will act like: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?
[–] J_Darnley 0 points 1 point 1 point (+1|-0) ago (edited ago)
No it won't. The second is equivalent to:
a++is "read then increment" whereas++ais "increment then read".