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 with
fscanf(file,"%50s\n",string);
the string only contains one word. when it bumps with a space it stops reading the string
fscanf(file,"%50[^\n]\n",string);
Every character except \n
will be consumed by [^\n]
Maximum 0f 50 chars will be consumed (make sure string has space for 51 atleast)
..
\n
",string
this makes sure that \n
is also consumed so that the next call does not just return a null string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With