当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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大神的英文原创作品 ++。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。