According to PHP documentation
mixed fscanf ( resource $handle , string $format [, mixed &$... ] )Each call to fscanf() reads one line from the file.
Now I am trying to read this output from a file using single fscanf()
These are line separated inputs.
8
4.0
is the best place to learn
using this code
fscanf("%d \n %f \n %[^\\n]");
but the output I am getting is
8
blank
blank
What is the correct code for it to read using single fscanf?
It is not possible to read multiple lines from a file with a single fscanf. An alternative is to call fscanf multiple times, one for each line. An alternative which will read all the lines in one go is the file() function.
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