how to read a string from a \n delimited file

后端 未结 5 455
天涯浪人
天涯浪人 2021-01-18 10:20

I\'m trying to read a return delimited file. full of phrases.

I\'m trying to put each phrase into a string.

The problem is that when I try to read the file w

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-18 10:52

    fscanf with %s stops reading when it finds whitespace.

    Since you are reading unformatted text, you can simply use fgets, which reads until it fills the buffer you give it, it finds a newline (\n), or it reaches the end-of-file, whichever comes first.

提交回复
热议问题