– – (decrement)

[Compound Operators]

描述

Decrements the value of a variable by 1.

語法

x--; // decrement x by one and returns the old value of x
--x; // decrement x by one and returns the new value of x

參數

X: variable. Allowed data types: intlong (possibly unsigned).

回傳

The original or newly decremented value of the variable.

Example Code

x = 2;
y = --x;  // x now contains 1, y contains 1
y = x--;  // x contains 0, but y still contains 1

語法參考主頁面

86Duino 參考的文本是根據 Creative Commons Attribution-ShareAlike 3.0 License,部分文本是從 the Arduino reference 修改的。 參考中的代碼示例已發佈到公共領域。

發表評論

上部へスクロール