C 中的 remove() 函數
remove() 函數定義在<stdio.h>
頭文件。
原型:
int remove(const char* filename);
參數: const char *filename
返回類型: int
函數的使用:
當我們處理文件時,有時我們需要擦除或刪除一些文件。在文件處理中,我們使用 remove() 函數來擦除文件。函數 remove() 的原型是int remove(const char* filename);
這裏,filename
是必須刪除的文件的名稱。如果文件被成功刪除,則返回零,如果發生錯誤則返回非零。
C 中的 remove() 示例
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE* f;
//Check the existence of that file
if ((f = fopen("includehelp.txt", "r")) == NULL) {
printf("File does not exist...\n");
}
else {
printf("File is exist.\n");
}
fclose(f);
//remove file
if (remove("includehelp.txt"))
printf("Remove error.....\n");
else
printf("File is removed\n");
//Check the existence of that file
if ((f = fopen("includehelp.txt", "r")) == NULL) {
printf("File does not exist...\n");
}
else {
printf("File is exist.\n");
}
fclose(f);
return 0;
}
輸出

相關用法
- C語言 rename()用法及代碼示例
- C語言 rewind()用法及代碼示例
- C語言 fread()用法及代碼示例
- C語言 feof()用法及代碼示例
- C語言 imagesize()用法及代碼示例
- C語言 getarcoords()用法及代碼示例
- C語言 strcspn()用法及代碼示例
- C語言 setlinestyle()用法及代碼示例
- C語言 showbits()用法及代碼示例
- C語言 sprintf()用法及代碼示例
- C語言 outtextxy()用法及代碼示例
- C語言 isgraph()用法及代碼示例
- C語言 grapherrormsg()用法及代碼示例
- C語言 moveto()用法及代碼示例
- C語言 putchar()用法及代碼示例
- C語言 tmpnam()用法及代碼示例
- C語言 putpixel()用法及代碼示例
- C語言 fillellipse()用法及代碼示例
- C語言 outtext()用法及代碼示例
- C語言 atan2()用法及代碼示例
注:本文由純淨天空篩選整理自Souvik Saha大神的英文原創作品 remove() function in C language with Example。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。