【发布时间】:2022-07-20 17:50:50
【问题描述】:
我需要根据用户的输入从目录中删除文件并将其传递给执行文件删除程序的函数
/* Class 3 veus 3:45PM*/
#include <string>
#include <iostream>
#include <stdio.h>
#include <cstdio>
void remove_file(std::string file);
int main() {
std::string file_name;
std::cin >> file_name;
remove_file(file_name);
}
void remove_file(std::string file) {
if(remove("C:\\MAIN_LOC\\" + file + ".txt") == 0) {
std::cout << "`" << file << "`" << " Item deleted successfully" << std::endl;
} else {
std::cout << "[Error] File not found";
}
}
好的,现在我在remove 函数上遇到了几个错误:function "remove" cannot be called with the given argument list。我不确定这个错误是什么意思,所以我想解释一下。
【问题讨论】:
-
附带说明,stdio.h 和 cstdio 是同一个东西,强烈建议在 C++ 中使用 cstdio 而不是 studio.h。
标签: c++