This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]