This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Problem with cin.getline()
- From: Waedt Karl NGLT <Karl dot Waedt at framatome-anp dot de>
- To: bug-gcc at gnu dot org
- Cc: Richter Jens NGLT <Jens dot Richter at framatome-anp dot de>
- Date: Thu, 13 Jun 2002 20:22:10 +0200
- Subject: Problem with cin.getline()
Dear sirs,
The following program does not work correctly when compiled with GCC 3.1.0,
tested on different workstations with SuSE Linux 8.0 and SuSE Linux 7.3.
Reading a single line from standard input requires hitting the <RETURN> key
twice.
#include <iostream>
using namespace std ;
int main(void) {
char buf[ 101 ] = "" ;
cin.getline( buf, 100 ) ;
cout << "|" << buf << "|\n" ;
}
Example input and output (only after second <RETURN>) with GCC 3.1.0:
FirstLine
SecondLine
|FirstLine|
Example input and output with GCC 3.0.4:
FirstLine
|FirstLine|
I would greatly appreciate a quick answer to the following questions:
Can you reproce the faulty behaviour?
If yes, will the error be corrected with GCC 3.1.1 ?
Sincere thanks
Karl
Dr. Karl Waedt
Framatome ANP, NGLTS
Freyeslebenstr. 1
91050 Erlangen
Phone: +49 9131 18 9 4813
Fax: +49 9131 18 9 2198
Karl.Waedt@framatome-anp.de