read %s %s %d %d to struct from records.dat using fscanf
Hello folks,
what i'm trying to do is to read data separated by whitespaces (' ', '\t') from file using fscanf
and put it into struct array
here's a piece of code:
Code:
typedef struct
{
char id[4], name[20];
int grade;
}rec;
...
rec recs [10]
...
while(fscanf(f, "%[^ ]%[^ ]%d", recs[i].id, recs[i].name, &recs[i],grade))
{
printf("%s %s %d", recs[i].id, recs[i].name, recs[i].grade);
i++;
}
it doesn't print it as it should.
i know that the problem is in reading (in second arg of fscanf)...
any ideas?