Home > Article > Backend Development > What does a-- mean in c++
The a-- in C is the postfix decrement operator. It calculates, decrements by 1, and updates the value of the variable a, and then decrements its value after the variable is used. Uses include: decrementing loop variables in loops, iterating over elements in arrays and lists, checking the value of a variable and decrementing it.
a--
in C In C, a--
is Postfix decrement operator, which decrements the value of variable a
by 1.
Syntax:
<code class="cpp">a--;</code>
Working principle:
a--
Decrease in the following steps# Value of ##a:
.
by 1.
.
Note:
,
a-- Decrement the value of a variable after using it.
returns the value after decrementing, while
--a returns the value before decrementing.
Example:
<code class="cpp">int a = 5; a--; // a 变为 4 cout << a; // 输出 4</code>
Use of postfix decrement operator:
a--Usually used when you need to use the current value of a variable and then decrement it. For example:
The above is the detailed content of What does a-- mean in c++. For more information, please follow other related articles on the PHP Chinese website!