檔案操作的幾個基本函式

2021-10-03 11:43:14 字數 353 閱讀 6762

.檔案操作中的函式要注意是對檔案進行操作,而不是對輸出螢幕進行操作(在對檔案進行操作前,要先開啟函式-fopen)

1,對檔案進行寫入時有以下函式(fputc fputs fwrite fprintf)

2,對檔案進行讀取時有以下函式(fgetc fgets fread fscanf)

3,對檔案操作完成後,要關閉檔案-fclose

另外檔案指標預設是指向檔案開頭,而要對檔案部分進行操作時

涉及到ftell(返回指標位置)函式、

fseek(移動指標)函式、

feof(判斷檔案執**況)函式

frewind(將指標移回檔案開頭)函式

fmove(刪除檔案)函式

幾個檔案操作函式

1.open 函式 功能描述 用於開啟或建立檔案,在開啟或建立檔案時可以指定檔案的屬性及使用者的許可權等各種引數。所需標頭檔案 include,include,include 函式原型 int open const char pathname,intflags,int perms 引數 pathna...

有關檔案操作的幾個函式

1.creat 1 函式的作用 建立,建立新檔案。2 函式的原型 int creat const char pathname,mode t mode 3 函式的引數 pathname 要建立的檔案路徑字串。如 home hello.c mode 建立檔案的許可權。4 函式的返回值 成功返回檔案描述符...

常用的幾個檔案操作函式

include includeint main include int main include int main void printf s n buf 在輸出時需要新增換行符 return 0 include int main void while c fgetc fp eof fclose f...