dlang怎么将const char转为string有多种方法都列出来
- 使用std::string的构造函数
const char* str = "hello";
std::string s(str);
- 使用std::string的assign函数
const char* str = "hello";
std::string s;
s.assign(str);
- 使用std::string的operator=
const char* str = "hello";
std::string s;
s = str;
- 使用std::stringstream
const char* str = "hello";
std::stringstream ss;
ss << str;
std::string s = ss.str();
原文地址: https://www.cveoy.top/t/topic/g0s3 著作权归作者所有。请勿转载和采集!