首页 > 代码库 > ISO C++ forbids comparison between pointer and integer

ISO C++ forbids comparison between pointer and integer

在g++下编译出现ISO C++ forbids comparison between pointer and integer错误

经过检查发现错误如下:

while (cin.get() !="\n")

     continue;

将其修改为:

while (cin.get() !=‘\n‘)

    continue;

在ISO C++中,"\n"常量字符串比较时是使用字符串的地址,所以为char *;

‘\n’字符,是转换为int常量的,可以与cin.get()比较

所以出现以上错误


ISO C++ forbids comparison between pointer and integer