[問題] 讀取文字檔
現在我有一份文字檔 內容是
Justin 90.5
momor 80.3
bush 75.7
我想使下列程式讀取 但是不論如何結果都是錯誤的
#include <stdio.h>
int main(int argc, char* argv[])
{
FILE * file = fopen("test.txt", "r");;
if (!file)
{
puts("無法讀入檔案");
return 1;
}
char name[40];
double score = 0;
while (fscanf(file, "%s %f", name, &score) != EOF)
printf("%s %f\n", name,score);
fclose(file);
return 0;
}
想請問是哪裡出了問題呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.117.238.68
※ 編輯: DennisTang 來自: 122.117.238.68 (03/06 13:26)
推
03/06 13:37, , 1F
03/06 13:37, 1F
→
03/06 13:53, , 2F
03/06 13:53, 2F