EOFEOF 代表檔案結尾。getc() 函式在成功時返回 EOF。以下是一個 C 語言中 EOF 的示例。假設我們有一個名為 "new.txt" 的檔案,其內容如下。This is demo! This is demo!現在,讓我們看看這個例子。示例#include <stdio.h> int main() { FILE *f = fopen("new.txt", "r"); int c = getc(f); while (c != EOF) { putchar(c); c = getc(f); } fclose(f); getchar(); return 0; }輸出This is demo! This is demo!在上面的程式中,使用 fopen() 開啟檔案。當整型變數 c ... 閱讀更多