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/