What is the difference in this line:
AndCode:while( c<10) { c++; }
In the way they function? JohnCode:while (c<10) { ++c; }
What is the difference in this line:
AndCode:while( c<10) { c++; }
In the way they function? JohnCode:while (c<10) { ++c; }
no difference
whitespace does not matter. It could just as easily be:though we'd have to castrate someone who writes it like that.Code:while (c < 10 ) { ++ c ;}
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
I think the OP was asking about post-increment versus pre-increment, not about the whitespace.
In this case, there is no practical difference. In other situations, it can make a difference.
Consider:
Code:int main(void) { int i=0; printf("Pre-increment: %d\t%d\n",++i,i); i=0; printf("Post-increment: %d\t%d\n",i++,i); return 0; }
Last edited by KBriggs; 10-26-2010 at 11:42 PM.
> printf("Pre-increment: %d\t%d\n",++i,i);
In particular, in this situation, the result is undefined behaviour.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Is it? Woops, my mistake. Apologies to the OP.