In your istream
, the trick is to compare a char
from the stream to 13
or 10
(depending if you are LF (ascii=10, found on UNIX-like systems)
or CRLF (ascii=13, ascii=10, found on Windows)
for newlines.
For example, given that ch
is the most recent char
from your istream
(LF
):
if(ch == 10)
// insert <br>
For (CRLF
), given that ch1
is the newest, and ch2
is the second newest:
if(ch1 == 10 && ch2 == 13)
// insert <br>
13
and 10
are the values for Carriage Return and Line Feed, respectively.
That's really all there is to it. It sounds like you can do the rest :)