— (decrement)

説明

変数の値を 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 int、long(場合によってはunsigned)

戻り値

変数の元の値または新たにデクリメントされた値。

コード例

x = 2;
y = --x;  // x now contains 1, y contains 1
y = x--;  // x contains 0, but y still contains 1
タイトルとURLをコピーしました