我遇到了一些文件IO問題。文件IO問題
我有這個文件:
db.dat:
Ryan
12 69.00 30.00 0.00
Bindy Lee
25 120.00 89.00 1.00
這是我的代碼:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define RECORDS 30
#define LEN 20
main()
{
FILE *fptr;
fptr = fopen("db.dat", "r");
int i;
int counter = 2;
for (i = 0; i < counter; i++)
{
char temp1[LEN];
char temp2[LEN + 10];
fgets(temp1, LEN, fptr);
fgets(temp2, LEN, fptr);
printf("%s %s", temp1, temp2);
}
fclose(fptr);
}
我應該得到兩條線,但我得到這個相反:
Ryan
12 69.00 30.00 0.00
Bindy Lee
有人可以請幫忙!我不知道爲什麼我沒有得到兩條線,爲什麼我得到空間。很奇怪......謝謝!
請從添加明確的呼聲有關問題標題不要幫助,有些人不喜歡回答問題這樣。 – hugomg
我很抱歉,我保證我不會做它一次。我是新來的CSE世界,正在學習的非正式規則。謝謝你告訴我,我會再次這樣做,不要。 – seyelent
它不是什麼大不了實際成交的。 – hugomg