You are viewing a single comment's thread.

view the rest of the comments →

0
2

[–] theNakedNecromancer 0 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?

0
1

[–] J_Darnley 0 points 1 point (+1|-0) ago  (edited ago)

No it won't. The second is equivalent to:

x = x * i;
i = i + 1;

a++ is "read then increment" whereas ++a is "increment then read".