What is the '-->' operator in C/C++?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
There is no special --> operator in C or C++. What you are seeing is the postfix decrement operator -- followed immediately by the greater-than operator >, and the expression is parsed according to normal language token rules.
How a-- > b Is Parsed
Consider this code:
This does not mean "arrow." It means:
- compare the current value of
atob, - then decrement
aafter the comparison expression uses the old value.
So if a starts as 10 and b is 5, the comparison uses 10 > 5, which is true, and only afterward does a become 9.
Why It Looks Confusing
The characters happen to look like an arrow when written together:
That visual resemblance is what confuses people. But the compiler sees two separate operators, not one combined token.
Common Loop Pattern
A classic example is a countdown loop:
The loop condition compares the old value of counter against 0, then decrements. That is why the printed values are 4, 3, 2, 1, 0.
Compare With Prefix Decrement
The behavior changes if you use prefix decrement instead:
Now the decrement happens first, and the comparison sees the new value. That difference between postfix and prefix decrement is more important than the visual --> shape.
Do Not Confuse This With ->
C and C++ do have a real arrow-like operator: ->. That one is completely different. It is used to access a member through a pointer.
So:
- '
-->is not a single operator,' - '
->is a real operator.'
Those two ideas are unrelated except for how they look on the page.
Readability Advice
Although counter-- > 0 is valid and common, it can be hard for beginners to parse quickly. If the code is performance-insensitive and clarity matters more, some teams prefer a more explicit form:
The compact version is fine when you understand it, but readability is still a design choice.
Expression Evaluation in Practice
It can help to imagine the postfix form as “use the current value, then subtract one afterward.” A tiny runnable example makes that visible:
This prints 1 and then 2. The comparison used the old value 3, and the decrement happened after that expression was evaluated.
Common Pitfalls
- Thinking
-->is a built-in operator. - Forgetting that postfix decrement uses the old value in the current expression.
- Confusing
a-- > bwith the real pointer-member operator->. - Using the compact form in code where readers may misinterpret it.
- Changing
a-- > bto--a > bwithout realizing the semantics changed.
Summary
- '
-->in C or C++ is not a special operator.' - It is parsed as
--followed by>. - '
a-- > bcompares first and decrements afterward.' - '
--a > bbehaves differently because prefix decrement happens first.' - Do not confuse this pattern with the real
->pointer-member operator.

