上课老师问这么个问题,怎么在程序中删除一个文件。上网查了个方法。
用remove函数
功 能: 删除一个文件
用 法: int remove( const char *filename);
头文件:在Visual C++ 6.0中可以用stdio.h
返回值:如果删除成功,remove返回0,否则返回EOF(-1)。

例:
1 #include <stdio.h>
2 
3 int main()
4 {
5  if(remove("1.txt"))
6  printf("Could not delete the file &s \n","1.txt");
7  else printf("OK \n");
8 return 0;
9 }


1.txt在程序目录下

相关文章:

  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2021-08-18
  • 2021-07-19
  • 2021-05-09
  • 2021-12-10
  • 2021-07-19
猜你喜欢
  • 2021-08-17
  • 2022-01-20
  • 2021-05-14
  • 2021-10-06
  • 2022-12-23
相关资源
相似解决方案