1.用地址输出字符数组
例如下列代码
#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;
int main(){
char n[20]={"hello world"};
cout<<n<<endl;
return 0;
}
这样写并不总是对。至于原因,暂不清楚。
2.对char进行运算
char类型可以进行数学运算,但是其只有4位,数值为0~127。在进行加减等数学运算时很容易越界,所以要慎重进行。