我想让一个字符串变成"test/",但我无法在初始字符串后添加斜杠。有任何想法和方法吗?
这是我目前尝试过的: 我得到了
string imgpath="test";
strcat(imgpath,"/");
这是我目前尝试过的: 我得到了
Error 1 error C2664: 'strcat' : cannot convert parameter 1 from 'std::string' to 'char *'
And another
imgpath="test"+"/";
Error 1 error C2110: '+' : cannot add two pointers
strcat
不应该用于std::string
。使用第二个代码片段 [或者使用 C 风格字符串,但这是一个更差的选择]。 - Mats Petersson