当char c = 0执行时,0是作为int类型赋给c,所以c对应的应该是ASCII值为0符号(空格),当然c==0是成立的,c=='0'不成立。
#include <iostream>
using namespace std;
int main()
{
char c = 0;
if (c == 0)
cout << "c==0" << endl;
else
cout << "end" << endl;
}
输出结果:c==0