您當前的位置:首頁 > 文化

用c語言新建文字後,如何關閉文字,舉例說明?

作者:由 傾聽你的心聲 發表于 文化時間:2019-01-08

#include

#include

int main()

{

//生成檔案

FILE *fpWrite=fopen(“test。txt”,“w”);

if(fpWrite==NULL) {

return 0;

}

char sRead[256];

fputs(“Hello, come on”,fpWrite); //寫檔案

fclose(fpWrite); //關閉檔案

FILE *fpRead=fopen(“test。txt”,“r”); //開啟檔案

if(fpRead==NULL) {

return 0;

}

fgets(sRead, 255, (FILE*)fpRead); //讀檔案

printf(“%s”,sRead); //輸送檔案內容

return 1;

}

標簽: fpWrite  檔案  file  return  sRead