Click to See Complete Forum and Search --> : cin.getline hanging up


pyrogyro125
April 23rd, 2003, 05:42 PM
Hi,

In my program, I have something like this:

cout << "Enter something: ";
cin >> something;
...

cout << "Enter something else: ";
cin.getline (something_else, 128);

Why is it that my program hangs up on the cin.getline when I have the first cin called? If I remove the first callout of cin, then the program works fine.

I've tried cout.flush(), thinking that it might work but it didn't.

Can someone please help?

mwilliamson
April 23rd, 2003, 06:14 PM
just change
cout << "Enter something: ";
cin >> something;
to
cout << "Enter something: ";
cin.width( 128 );
cin >> something;