字符串中的0 其实是“0” 而不是 bool 的0

#include <iostream>
using namespace std;
int main()
{
    char *p=NULL;
    p="com\0hputer";
    while(*p){

          cout << *p;
          p++;
    }

    return 0;
}
输出com

#include <iostream>
using namespace std;
int main()
{
    char *p=NULL;
    p="com0hputer";
    while(*p){

          cout << *p;
          p++;
    }

    return 0;
}

输出 com0hputer


说明 字符串的0 其实是“0” 而不是 bool 的0

 if('0'=="0")
    {
        cout<<"y";
    }

 

error: ISO C++ forbids comparison between pointer and integer|

一个是char,一个是char * C++规定不能比较       C可以

 

posted @ 2014-01-20 22:19  zj一乐  阅读(452)  评论(0)    收藏  举报