This function reads characters up to 100 characters at a time,
and is meant to add a \r after each newline; it relies on the
behavior of fgets() that only reads up until a newline or EOF.
Under an assumption that all the lines in the file to be read
are less than 100 characters long, this works as expected,
translating \n into \n\r. However, if a line is longer
than 100 characters, this ends up inserting a \r into the
middle of the line, since fgets() will also stop reading if
it hits the maximum character limit even without finding a
newline.
This function reads characters up to 100 characters at a time, and is meant to add a
\r
after each newline; it relies on the behavior offgets()
that only reads up until a newline or EOF. Under an assumption that all the lines in the file to be read are less than 100 characters long, this works as expected, translating\n
into\n\r
. However, if a line is longer than 100 characters, this ends up inserting a\r
into the middle of the line, sincefgets()
will also stop reading if it hits the maximum character limit even without finding a newline.