将正斜杠添加到字符串

乔治·伊里米奇科(George Irimiciuc)

我想将字符串设置为“ test /”,但不能在初始字符串之后添加斜杠。知道为什么以及如何吗?

string imgpath="test";
strcat(imgpath,"/");

到目前为止,这是我尝试过的。我懂了

Error   1   error C2664: 'strcat' : cannot convert parameter 1 from 'std::string' to 'char *'

还有一个

imgpath="test"+"/";

Error   1   error C2110: '+' : cannot add two pointers
一切都在流动

使用std::string::operator+=()代替strcat()

string imgpath="test";
imgpath += "/";

至于你的第二个例子

imgpath=std::string("test") +"/";

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章