用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;
}
上一篇:植物也分“早起鳥”和“夜貓子”?
下一篇:你聽過哪些惡有惡報的事兒?