I need to read a line of text (terminated by a newline) without making assumptions about the length. So I now face to possibilities:
fgets
and
If you can set a maximum line length, even a large one, then one fgets
would do the trick. If not, multiple fgets
calls will still be faster than multiple fgetc
calls because the overhead of the latter will be greater.
A better answer, though, is that it's not worth worrying about the performance difference until and unless you have to. If fgetc
is fast enough, what does it matter?