1.remove
remove函数用来删除一个文件。
#include <stdio.h>
int remove(const char *pathname);
实例:
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
//#include <unistd.h>
//windows下无法打开源文件"unistd.h"采用以下方式解决
#ifndef _UNISTD_H
#define _UNISTD_H
#include <io.h>
#include <process.h>
#endif
int main(int argc, char const *argv[])
{
if(remove("./test.txt")==-1){
perror("fail to remove file:");
return -1;
}
printf("delete file success!");
return 0;
}