CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2003
    Posts
    3

    cin.getline hanging up

    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?

  2. #2
    Join Date
    Dec 2001
    Location
    Ontario, Canada
    Posts
    2,236
    just change
    cout << "Enter something: ";
    cin >> something;
    to
    cout << "Enter something: ";
    cin.width( 128 );
    cin >> something;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured