gpt4 book ai didi

c++ - C++中的文件删除

转载 作者:太空狗 更新时间:2023-10-29 23:31:08 26 4
gpt4 key购买 nike

我想删除一个文件,其路径存储在 std::string 中目的。我知道remove()<cstdio> , 但它需要 const char *作为论据。那么有没有直接删除文件的方法,比如以字符串对象为输入的函数?

最佳答案

怎么样:

string fileName;
//...
remove(fileName.c_str());

当然,你可以随时定义

int remove(std::string const& fileName)
{
return remove(fileName.c_str());
}

关于c++ - C++中的文件删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9019394/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com