vendredi 8 mai 2015

fscanf function doesn't read in c

I tried to read some data from file and insert it to queue, Insert function works well, and i tried to catch the error with printfs. I saw that in while() line there is error. The data in file forms like that

12345 2

11232 4

22311 4

22231 2

void read_file(struct Queue *head){
FILE *fp;
int natid;
int cond;
fp=fopen("patients.txt","r");

    while (fscanf(fp,"%d %d", natid, cond) != EOF)
        insert(head,natid,cond);

fclose(fp);}

Aucun commentaire:

Enregistrer un commentaire