C++ 解决 string 转 char* 乱码

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/Simon798/article/details/102507963
char* stringToCharP(std::string str){
	
	// 初始化 result 
	char* result = new char[str.length()+1];
	
	// 赋值 result
	strcpy_s(result,str.length()+1,str.c_str());
	
	return result;
}

猜你喜欢

转载自blog.csdn.net/Simon798/article/details/102507963
今日推荐