What is the name of the “-->” operator?(Stackoverflow)

Posted slgkaifa

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了What is the name of the “-->” operator?(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 decrementing x, while returning x‘s original (not decremented) value, and then comparing the original value with 0 using the > operator.

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

while( (x--) > 0 )

以上是关于What is the name of the “--&gt;” operator?(Stackoverflow)的主要内容,如果未能解决你的问题,请参考以下文章

What is the bottleneck and weakness of AlphaGo?

What is the maximum length of a URL in different browsers?

text 来自https://stackoverflow.com/questions/7943751/what-is-the-python-3-equivalent-of-python-m-simpl

where is the name of Teddy come from?

[SF] The term 'Add-AzServiceFabricClusterCertificate' is not recognized as the name of a cmd

Hive 2.3.4 Name node is in safe mode. The reported blocks xxx has reached the threshold 0.9990 of to