char盲区
yichen
posted @ 2014年4月01日 00:29
in Essay
, 368 阅读
#include <iostream>
using namespace std;
int main()
{
char *a = "hello";
char b[10] = "hello!";
cout << sizeof(a) << endl
<< sizeof(b) << endl
<< a << endl
<< b << endl
<< a[4] << b[4] << endl
<< a[5] << b[9] << endl;//注意输出结果
a = "ketty";
// a[1] = 'a';//不能对其赋值,其为常量
cout << a << endl;
return 0;
}
运行结果:
4
10
hello
hello!
oo
ketty