當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Arduino ++用法及代碼示例

[複合運算符]

說明

將變量的值增加 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:變量。允許的數據類型:intlong(可能是無符號的)。

返回

變量的原始值或新增加的值。

示例代碼

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

相關用法


注:本文由純淨天空篩選整理自arduino.cc大神的英文原創作品 ++。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。