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