Skip to content

Instantly share code, notes, and snippets.

@ruyut
Created March 28, 2019 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruyut/878401b0d9e03dd24b355b4ac303d970 to your computer and use it in GitHub Desktop.
Save ruyut/878401b0d9e03dd24b355b4ac303d970 to your computer and use it in GitHub Desktop.
//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