What is the name of this operator: “--”?
stackoverflow.com
What is the name of this operator: “--”?
1–10 of 11 posts
Re: What is the name of this operator: “--”?
#2Re: What is the name of this operator: “--”?
#3[1]: http://stackoverflow.com/questions/1642028/what-is-the-name-...
Re: What is the name of this operator: “--”?
#4Could someone break this down and explain it to me? [1] It looks hilariously atrocious yet interesting at the same time. [1]: http://stackoverflow.com/questions/1642028/what-is-the-name-...
#define as ;while
...
do printf("n is %d\n", n) as ( n --> 0);
Parses to (white space adjusted for clarity): do printf("n is %d\n", n);
while ( n-- > 0);Re: What is the name of this operator: “--”?
#5Could someone break this down and explain it to me? [1] It looks hilariously atrocious yet interesting at the same time. [1]: http://stackoverflow.com/questions/1642028/what-is-the-name-...
do {
printf("%d",x);
} while (x-- > 0);Re: What is the name of this operator: “--”?
#6Re: What is the name of this operator: “--”?
#7Re: What is the name of this operator: “--”?
#8Could someone break this down and explain it to me? [1] It looks hilariously atrocious yet interesting at the same time. [1]: http://stackoverflow.com/questions/1642028/what-is-the-name-...
The answer that shows it with the brackets is probably the clearest:
while ((x--) > 0)
{ ... }
The compiler sees that as the same as (x--> 0)So it checks if x is more than zero and then decrements it each loop iteration.
Re: What is the name of this operator: “--”?
#9The title is missing a >. Should be "-->"