接着上一篇,如果找到同名文件,则要把同名文件删除
//deletefile.cpp
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
char *savePath = "/home/zhuwei/contour/linearIteration.shp";
if(remove(savePath)==0)
{
cout<<"删除成功"<<endl;
}
else
{
cout<<"删除失败"<<endl;
}
return 0;
}
编译:g++ -o deletefile deletefile.cpp
执行:./deletefile
OK,执行通过