Last Update 2012/07/05
ファイルを閉じます(ファイル・ポインタとファイルの接続を解除)。
戻り値1 = fclose( 引数1 )
戻り値1 :
int
実行が成功した場合
0
エラーが発生した場合
EOF
引数1 :
FILE *
ファイル・ポインタ
(例)
#include <stdio.h>
int main()
{
char s1[20] = "123456789";
char s2[20];
int nret;
FILE *fp;
fp = fopen("test_fopen_w.txt", "w");
nret = fputs(s1, fp);
printf("実行結果「w」 : %d\n", nret);
fclose(fp);
fp = fopen("test_fopen_w.txt", "r");
fgets(s2, 20, fp);
printf("ファイル内文字列 : %s\n", s2);
fclose(fp);
return 0;
}
実行結果
実行結果「w」 : 9
ファイル内文字列 : 123456789