- 论坛徽章:
- 0
|
char *a1 = "abc";
char *a2 = "abc";
char b1[] = "abc";
char b2[] = "abc";
const char *c1 = "abc";
const char *c2 = "abc";
char *d1 = (char*)malloc(4);
char *d2 = (char*)malloc(4);
strcpy(d1, "abc");
strcpy(d2, "abc");
static char e1[] = "abc";
static char e2[] = "abc";
static char *f1 = "abc";
static char *f2 = "abc";
cout << (a1==a2) << endl;
cout << (b1==b2) << endl;
cout << (c1==c2) << endl;
cout << (d1==d2) << endl;
cout << (e1==e2) << endl;
cout << (f1==f2) << endl;
输出结果:
1
0
1
0
0
1
各个声明的声明分别在什么地方,为什么会有些相等,有些不等。 |
|