char STR[] = "Hello\!";
有六个字符,但
cout << sizeof(STR);
的结果是7,因为后面还有一个结束符 "\0"。
for(int i = 0 ; i<=6; i++){
cout<<STR[i]; }
一样可以输出 Hello!
char STR[] = "Hello\!";
有六个字符,但
cout << sizeof(STR);
的结果是7,因为后面还有一个结束符 "\0"。
for(int i = 0 ; i<=6; i++){
cout<<STR[i]; }
一样可以输出 Hello!