C, how to use fgets and fscanf together

后端 未结 1 1162
温柔的废话
温柔的废话 2021-01-16 04:26

i hav a homework form univ. that is use file IO.

there is like this TXT file:

Brian
s213551 50 70 70 50
Alex Fernandes
s210011 70 81 50 89
Young Lee
         


        
1条回答
  •  旧巷少年郎
    2021-01-16 05:25

    Just add a space in the end of fscanf() parameter to consume the newline character.

    fscanf(f, "%s %d %d %d %d ", member[i].id, &member[i].score[0], &member[i].score[1], &member[i].score[2], &member[i].score[3]);
    

    0 讨论(0)
提交回复
热议问题