您的位置:首页 > 其它

字符串数组和字符串指针的差别

2015-10-06 17:00 351 查看
源代码:

#include<iostream>

using namespace std;

int main()
{
char a[] = "string";
char b[] = "string";
bool test = a==b;
cout<<"a[]?b[]:"<< boolalpha<<test<<endl;

char *c = "string";
char *d = "string";
test = (c==d);
cout<<"*c?*d:"<<boolalpha<<test<<endl;

char e[10] = "string";
char f[10] = "string";
test = (e==f);
cout<<"e[10]?d[10]:"<<boolalpha<<test<<endl;

return 0;
}


运行结果:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: