Created
February 23, 2026 02:44
-
-
Save bg1bgst333/396d960d6656c1c5ce703abbba207aca to your computer and use it in GitHub Desktop.
EOF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* ヘッダファイルのインクルード */ | |
| #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