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

Dennis Muhlestein djmuhlestein at
Wed Feb 15 16:56:14 MST 2012

On 2/15/12 3:50 PM, Byron Clark wrote:
> On 02/15/12 at 03:46pm, John Shaver wrote:
>> 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.

One thing I've done in the past is to read in a line at a time with 
getline and then parse each line character at a time instead of parsing 
the whole file character by character. Then you don't have to add little 
tweaks for '\r' that don't really have to do with your bus logic.

#include <iostream>
#include <fstream>

using namespace std;

int main(int argc, char* argv[] ) {

  ifstream infile("test.txt");
  string line;
  for (; !infile.eof(); getline(infile,line) ) {
	cout << "Got a line: " << line << endl;
	// parse it however now...

return 0;


More information about the PLUG mailing list