char[]轉char*
char charArray[]="Hello World";
char* charList=charArray;
char[]轉string
char charList[]="Hello World";
string str=charList;
char*轉string
char* charList="Hello World";
string str=charList;
string轉char[]
string str="Hello World";
char charArray[str.length()+1];
strcpy(charArray, str.c_str());
string轉char*
string str="Hello World";
char* charList=const_cast<char *>(str.c_str());
注意
使用 char[] 時一定要注意長度+1,因為他有一個 '\0' 字符,但不顯示表達出來