Hello,
I'm writing a program using the g++ compiler that runs under Cygwin in
Windows, and have written the following:
std::ifstream file;
char buffer[128];
std::string myString;
file.open(filename);
file.getline(buffer,128);
myString=buffer;
This ought to open filename in text mode so all instances of \r\n will be
replaced with \n, and no line ending characters end up in myString.
However, when I actually run this, I end up with a \r character on the end
of all my strings. Where did I go wrong? The Cygwin documentation
(http://www.cygwin.com/cygwin-ug-net/...extbinary.html) assures me that
it defaults to opening files in text mode as it should.
Incidentally, coming from a Java background, having to define a fixed size
buffer seems very aukward. Can it be avoided?
Thanks,
Alex Gerdemann
University of Illinois Urbana-Champaign