1、
char str1[] = "abc";
char str2[] = "abc";const char str3[] = "abc";
const char str4[] = "abc";
const char* str5 = "abc";
const char* str6 = "abc";
cout << ( str1==str2 ) << endl; // 输出什么?
cout << ( str3==str4 ) << endl; // 输出什么?
cout << ( str5==str6 ) << endl; // 输出什么?
验证:
#include<iostream>
using namespace std;
int main()
{
char str1[] = "abc";
char str2[] = "abc";
const char str3[] = "abc";
const char str4[] = "abc";
const char* str5 = "abc";
const char* str6 = "abc";
cout << ( str1==str2 ) << endl; // 输出什么?
cout << ( str3==str4 ) << endl; // 输出什么?
cout << ( str5==str6 ) << endl; // 输出什么?
cout << static_cast<const void*>(str1)<<endl;
cout << static_cast<const void*>(str2)<<endl;
cout << static_cast<const void*>(str3)<<endl;
cout << static_cast<const void*>(str4)<<endl;
cout << static_cast<const void*>(str5)<<endl;
cout << static_cast<const void*>(str6)<<endl;
return 0;
}
结果:
0
0
1
0xbfceb76c
0xbfceb770
0xbfceb774
0xbfceb778
0x8048a80
0x8048a80