Skip to main content
added 14 characters in body; edited title
Source Link
CPlus
  • 4.4k
  • 35
  • 25
  • 47

What is the "'-->">' operator in C++C/C++?

After reading Hidden Features and Dark Corners of C++/STL on comp.lang.c++.moderated, I was completely surprised that the following snippet compiled and worked in both Visual Studio 2008 and G++ 4.4. I would assume this is also valid C since it works in GCC as well.

Here's the code:

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

Output:

9 8 7 6 5 4 3 2 1 0

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?

What is the "-->" operator in C++?

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

Here's the code:

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

Output:

9 8 7 6 5 4 3 2 1 0

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?

What is the '-->' operator in C/C++?

After reading Hidden Features and Dark Corners of C++/STL on comp.lang.c++.moderated, I was completely surprised that the following snippet compiled and worked in both Visual Studio 2008 and G++ 4.4. I would assume this is also valid C since it works in GCC as well.

Here's the code:

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

Output:

9 8 7 6 5 4 3 2 1 0

Where is this defined in the standard, and where has it come from?

Question is clearly about C++ (it refers to Hidden Features and Dark Corners of C++/STL comp.lang.c++.moderated, G++)
Link
mip
  • 8.6k
  • 6
  • 55
  • 74

What is the "-->" operator in C/C++C++?

`c tag` is enough because `c++` is a superset of `c`
Link
Darth-CodeX
  • 2.3k
  • 2
  • 9
  • 25
edited title
Link
Josu Goñi
  • 1.2k
  • 1
  • 13
  • 28
Loading
Rollback to Revision 34
Source Link
Gerhardh
  • 12.2k
  • 4
  • 17
  • 40
Loading
correct representions for unary operator.
Source Link
Loading
edited tags
Source Link
S.S. Anne
  • 15.4k
  • 8
  • 40
  • 80
Loading
Rollback to Revision 26
Source Link
S.S. Anne
  • 15.4k
  • 8
  • 40
  • 80
Loading
Notice removed Reward existing answer by Kalana
Bounty Ended with Jay Riggs's answer chosen by Kalana
Notice added Reward existing answer by Kalana
Bounty Started worth 100 reputation by Kalana
Fix output code block.
Source Link
Exr0n
  • 358
  • 1
  • 9
Loading
added 18 characters in body
Source Link
Kalana
  • 6k
  • 7
  • 33
  • 53
Loading
added 8 characters in body; edited tags
Source Link
Kalana
  • 6k
  • 7
  • 33
  • 53
Loading
Rollback to Revision 26
Source Link
MultiplyByZer0
  • 6.9k
  • 3
  • 33
  • 48
Loading
I have highlighted some parts of your code to easy understand pupose
Source Link
Kalana
  • 6k
  • 7
  • 33
  • 53
Loading
Improved title
Link
Steve Chambers
  • 38.7k
  • 28
  • 168
  • 217
Loading
edited tags
Link
Fingolfin
  • 5.5k
  • 6
  • 46
  • 66
Loading
Put C++ in the title to make consistent with other top questions and better in Google
Source Link
Steve Chambers
  • 38.7k
  • 28
  • 168
  • 217
Loading
Post Merged (destination) from stackoverflow.com/questions/34513787/…
spelling fix/rollback
Source Link
user1350534
user1350534
Loading
improved formating
Source Link
Yahs Hef
  • 797
  • 9
  • 24
Loading
clarified what 'it' represented
Source Link
Loading