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。在進行加減等數學運算時很容易越界,所以要慎重進行。