不说了,开代码:
.h文件(头文件): //为了规范取名为file.h
#include <iostream>
#include <fstream>
int fkill(const char* ftm)//用于删除指定文件
{
const char* file_path = ("%s",ftm);
if (remove(file_path) != 0) {
cout << "失败" << endl;
}
else {
cout << "成功" << endl;
}
return 0;
}
.cpp(c加加文件):
#include "file.h"
int main()
{
fkill("a.txt");//这里"a.txt"只是实例,只要输入要删除的文件的路径就可删除
}
破10赞火速更新下一期