Created
March 28, 2019 05:18
-
-
Save ruyut/878401b0d9e03dd24b355b4ac303d970 to your computer and use it in GitHub Desktop.
This file contains 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
//904-2 | |
#include<stdlib.h> | |
#include<stdio.h> | |
int main() { | |
FILE *fi;//宣告檔案指標 | |
char name[20];//宣告字元陣列 | |
int score;//宣告變數 | |
fi = fopen("score.dat", "r"); //使用讀取的方式開啟檔名為score.dat的檔案 | |
while (fscanf(fi, "%s %d", name, &score) != EOF)//如果讀不到資料時跳出 | |
printf("%s的C語言分數是%d\n", name, score); //列印名字和分數 | |
fclose(fi);//關閉檔案 | |
system("PAUSE");//等待使用者按下任意按鍵 | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment