C++删除文件

接着上一篇,如果找到同名文件,则要把同名文件删除

//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,执行通过

上一篇:dom4j解析xml文件简单版


下一篇:自建 K8S 集群迁移到裸金属服务器