gpt4 book ai didi

c++ - 分配递增变量

转载 作者:太空宇宙 更新时间:2023-11-03 10:23:36 24 4
gpt4 key购买 nike

PORTB = pattern ++;
//The author explains te upper code with the code below
pattern = pattern + 1;
PORTB = pattern;

PORTB = ++ pattern; //That's what I think is right

我认为这段代码是错误的,因为在语句中使用后后增量应该加1,所以对于下面的代码,必须有一个前增量e。但由于我对 c/c++ 不太熟悉(只读过一本书),我想知道是我搞砸了什么,还是作者错了。

编辑:这本书不是关于 c/c++ 的,而是关于 arduino 的。

最佳答案

你是对的

PORTB = pattern++;

相当于

PORTB = pattern;
pattern = pattern + 1;

关于c++ - 分配递增变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50608320/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com