pamxy

为了那么丁点的兴趣,你懂的...

导航

remove

转自:百度百科  http://baike.baidu.com/view/982238.htm#2


C语言中的Remove函数

简介

功 能: 删除一个文件,相当于unlink函数,但是如果它的filename参数是一个目录的话,其作用就相当于rmdir函数。
用 法: int remove(const char *filename);
remove函数图片

  remove函数图片

头文件:在Visual C++ 6.0中可以用stdio.h也可以用io.h,前者更普遍。
返回值:如果删除成功,remove返回0,否则返回EOF(-1)。

程序例:

#include <stdio.h>
int main(void)
{
char file[80];
/* prompt for file name to delete */
printf("File to delete: ");
gets(file);
/* delete the file */
if (remove(file) == 0)
printf("Removed %s.\n",file);
else
perror("remove");
return 0;
}

posted on 2013-03-05 11:22  pamxy  阅读(648)  评论(0编辑  收藏  举报