我在c ++中有一个char数组。例如:
char input[]="I love you";
我想做一个std :: string从char [i]到char [j]。例如 :
std::string output="love";
我该怎么办?
你可以这样做:
char input[]="I love you";
std::string str(input);
此处:http : //www.cplusplus.com/reference/string/string/string/
如果您只想要一部分,请编写以下代码:
std::string str(input + from, input + to);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句