If you must reproduce the line breaks you must read line-wise, probably with
fgets
. (The usual problem of "max line length" exists (hopefully, your assignment specifies one).) You can then read the line in the buffer which you have read with fgets
using sscanf
, using the n
specifier to keep track of the read position in the string.