|
|
|||||
|
Get the Ebook
C Tutorial
Source Code
Function Reference
|
Don't increment the same variable multiple times in one statementThis tip submitted by sidra on 2010-01-31 15:15:39. It has been viewed 1710 times.Rating of 3.0 with 4 votes Don't write code like this! It is hard to read and might not always work as you expect, as it depends on the code generated by the compiler:
printf("%d%d%d",a++,a,++a);
Instead be clear about the order you want the increments to happen:
printf("%d",a++)
printf("%d",a)
printf("%d",++a)
More tips Help your fellow programmers! Add a tip!
Want to become a C++ programmer? The Cprogramming.com ebook, Jumping into C++, will walk you through it, step-by-step. Get Jumping into C++ today!
Popular pages
Custom Search
|
||||