Reading one line at a time in C

后端 未结 10 884
萌比男神i
萌比男神i 2020-12-01 13:01

Which method can be used to read one line at a time from a file in C?

I am using the fgets function, but it\'s not working. It\'s reading the space

10条回答
  •  醉话见心
    2020-12-01 13:44

    This is more of a comment than a complete answer, but I don't have enough points to comment. :)

    Here's the function prototype for fgets():

    char *fgets(char *restrict s, int n, FILE *restrict stream);
    

    It will read n-1 bytes or up to a newline or eof. For more info see here

提交回复
热议问题