标签:转换 nbsp ++ int pre code i++ abc c_str
1.string-->char *,
调用string的方法c_str()或者data();
string str = "abc"; char *pChar = (char *)str.data();
2.char *-->string
char *pTemp = "abcdef"; string tmpStr(pTemp);
3.string-->char[]
string str = "abcdefg"; char p[10]; int i = 0; for (i = 0; i < str.length(); i++) { p[i] = str[i]; } p[i] = ‘\n‘;
4.char[]-->string
char p[10] = "abcdefg"; string str1 = p;
标签:转换 nbsp ++ int pre code i++ abc c_str
原文地址:https://www.cnblogs.com/zwj-199306231519/p/13362586.html