Weird glitch/bug with c++ program compiled in Ubuntu? or am I doing something wrong?

John Shaver bobjohnbob at
Wed Feb 15 15:46:11 MST 2012

On Wed, Feb 15, 2012 at 3:25 PM, Andrew McNabb <amcnabb at> wrote:
> It looks like you're having a problem with line endings.  Your program
> checks for a newline ('\n'), but it doesn't treat carriage return ('\r')
> specially.  At some point, the program prints out the carriage return,
> which on Linux causes all of the input on the line to be erased.

Yeah, that was it.  Instead of just removing the \n, I had it remove
either \n or \r until neither were present.  That seems to have fixed
it.  Thanks for pointing it out to me.  Running dos2unix on the
text.txt file also 'fixed' it :)

It kind of makes file processing strange if windows compilers treat
\r\n different than linux based compilers...  They should both just
treat them as what they are.  Otherwise, writing cross platform code
is more difficult.


John Shaver

More information about the PLUG mailing list