C语言的文件操作想必大家都多多少少的有所了解,今天为大家献上删除文件的操作方法。这里我们要用到的是remove(const T& x);x使用代表文件路径及文件名的字符常量来确定需要删除的对象。下面是源码:
1 #include <stdio.h>
2
3 int main()
4
5 {
6
7 char a[20];
8
9 printf(“please input a file:”);
10
11 scanf(“%s”,a);
12
13 if(remove(a))
14
15 printf(“Could not delete the file &s \n”,”1.txt”);
16
17 else printf(“OK \n”);
18
19 return 0;
20
21
谢谢支持!