百科学堂 | 实用工具

string和char*互转



char*转string:


char* a="hello";


string s=string(a,strlen(a));


或者直接转 s=a;


string转char*:


string s="hello";


char* p=s.data();//可能不行


或者


char* p=s.c_str();


本文版权:http://www.ndfweb.cn/news-905.html
NDF网站建设淘宝店 | 联系我们
©2007-2025 NDF Corporation