C语言删除指定文件

来源:互联网 发布:淘宝账号怎么找回来 编辑:程序博客网 时间:2024/05/01 21:01
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 }

 

谢谢支持!

可以联系我进行交流。Renhanlinbsl@163.com

 

2015.3.27

22:30

 

0 0