运算顺序有关,详见 运算符优先级
代码1:
#include<iostream> using namespace std; int main() { char c; int m=0; while( c= getchar(c) &&c!=' ') { m++; cout<<"case:"<<m<<endl; cout<<c<<endl; } return 0; }
代码2:
#include<iostream> using namespace std; int main() { char c; int m=0; while( (c= getchar(c)) &&c!=' ') { m++; cout<<"case:"<<m<<endl; cout<<c<<endl; } return 0; }