Sin骑士 2015-04-28 13:01 采纳率: 0%
浏览 2602

关于C/C++中char*之间的比较和数组之间的比较的问题

char a[] = "abc";
char b[] = "abc";
char* c = "abc";
char* d = "abc";

if( a==b )
{
    cout<< "a[] and b[] are equal!" << endl;
}else if( a!=b )
{
      cout<< "a[] and b[] are not equal!" << endl;
}

if( c==d )
{
      cout<< "*c and *d are equal!" << endl;
}else if( c!=d )
{
      cout<< "*c and *d are not equal!" << endl;
}

请问输出结果是什么?为什么是这种结果?
  • 写回答

7条回答 默认 最新

  • 纵横车 2015-04-28 13:06
    关注

    a,b,c,d都是什么呀?把他们的声明写出来看看。

    评论

报告相同问题?