//删除原来new文件
#include<iostream>
#include<cstdio>
#include <string.h>
#include <unistd.h>
using namespace std;
//cmakelist中要添加c++11 set(CMAKE_CXX_STANDARD 11)
int main(){
int count = 1;
while (1) {
string filepath = "/home/cai/mrpt/mrpt15/mrpt/apps/GridmapNavSimul/new" + to_string(count)+".pgm";
char filename_buf[filepath.size()];
strcpy(filename_buf, filepath.c_str());
if (access(filename_buf, 0) == -1) {
std::cout << "no file to remove" << std::endl;
break;
}
remove(filename_buf);
count++;
}
return 0;
}
网友评论