James Harper <james.harper(a)bendigoit.com.au> wrote:
Is there a library routine like fgets() but which takes any of CR, NL, and
CR+NL as an end of line?
I'm pretty sure there isn't. Is using sscanf out of the question? You may be
able to construct a format string that does what you want unless you really
do want a CR by itself to also represent a linefeed (which I can't think how
to do using sscanf).
You could write a function to do this without much trouble though.
CR alone is the real problem here: if you were only concerned with LF or CR+LF
then all you would have to do is deal with the case in which there's an
extraneous CR at the end of the buffer (you could simply change it to '\0', I
suppose, and ensure that the buffer is long enough for the expected lines,
including trailing CR).