What is the name of the "-- & gt;" operator? (Stackoverflow), stackoverflow

Source: Internet
Author: User

What is the name of the "-->" operator? (Stackoverflow), stackoverflow

Question:

After reading Hidden Features and Dark Corners of C ++/STL on comp. lang. c ++. moderated, I was completely surprised that it compiled and worked in both Visual Studio 2008 and G ++ 4.4.

The code:

#include <stdio.h>int main(){     int x = 10;     while( x --> 0 ) // x goes to 0     {       printf("%d ", x);     }}

I 'd assume this is C, since it works in GCC as well. Where is this defined in the standard, and where has it come from?

Answer:

That's not an operator-->. That's two separate operators,--And>.

The condition code is decrementingx, While returningx'S original (not decremented) value, and then comparing the original value0Using>Operator.

To better understand, the statement cocould be written as follows:

while( (x--) > 0 )

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.