我对C ++比较陌生,我想知道如何删除文件 - 基于传递一个目录。我试过这样做,但它不起作用。 代码:
remove (".\\Players\\" + getPlayerUsername() + "\\Balance.txt");
错误:
11 IntelliSense: no instance of overloaded function "remove" matches the argument list
argument types are: (std::string)
我正在使用Visual Studio 2013(我不喜欢)。
谢谢:-) KJ
答案 0 :(得分:1)
更改为
remove ((".\\Players\\" + getPlayerUsername() + "\\Balance.txt").c_str());
<强> ===编辑=== 强>
警告显示您的表达式评估为std::string
,而删除则需要const char*
。 std::string
有一个方法.c_str()
,它会向您的字符串返回const char*
指针。