++

[Compound Operators]

描述

Increments the value of a variable by 1.

語法

x++; // increment x by one and returns the old value of x
++x; // increment x by one and returns the new value of x

參數

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

回傳

The original or newly incremented value of the variable.

Example Code

x = 2;
y = ++x;  // x now contains 3, y contains 3
y = x++;  // x contains 4, but y still contains 3

語法參考主頁面

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

發表評論

上部へスクロール