Skip to content

Instantly share code, notes, and snippets.

@bg1bgst333
Created February 23, 2026 02:44
Show Gist options
  • Select an option

  • Save bg1bgst333/396d960d6656c1c5ce703abbba207aca to your computer and use it in GitHub Desktop.

Select an option

Save bg1bgst333/396d960d6656c1c5ce703abbba207aca to your computer and use it in GitHub Desktop.
EOF
/* ヘッダファイルのインクルード */
#include <stdio.h> /* 標準入出力 */
/* main関数の定義 */
int main(void){
/* 変数の宣言 */
FILE *fp;
int value;
int result;
/* 無限ループでファイルを読み込む. */
fp = fopen("test.txt", "r");
if (fp == NULL){
return 1;
}
while (1){
result = fscanf(fp, "%d", &value);
if (result == EOF){ /* EOFなら. */
printf("(EOF)\n"); /* "(EOF)"を出力. */
break;
}
printf("%d\n", value); /* 読み込めた値を出力. */
}
fclose(fp);
/* プログラムの終了 */
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment