#include <iostream>
#include <cstring>
using namespace std;
int main() {
char *str = "hello";
while (*str) {
cout << *str;
*str++;
}
return 0;
}
和
#include <iostream>
#include <cstring>
using namespace std;
int main() {
char *str = "hello";
while (*str) {
cout << *str;
str++;
}
return 0;
}
两个输出
hello
为什么在str++
更改输出之前不添加或删除引用运算符?
*str++
意味着*(str++)
。
由于您不使用该表达式的值,因此*
无效。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句