Thread: STL question: getline

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    552

    STL question: getline

    i have this code:

    string str;
    while (getline(cin, str, '\n')) {
    ....

    and i enter something like, say, "Hello everybody<enter>" (where <enter> is the return key). Getline refuses to return until I press enter again. Why is this so? Is there any way around this?
    C Code. C Code Run. Run Code Run... Please!

    "Love is like a blackhole, you fall into it... then you get ripped apart"

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Here is one solution.

    Code:
    string sText;
    std::getine(cin, sText);
    Kuphryn

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    thats exactly what i have...
    C Code. C Code Run. Run Code Run... Please!

    "Love is like a blackhole, you fall into it... then you get ripped apart"

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    I'll assume that you use MSVC++ 6. This is a bug in the compiler, MSDN gives a fix for it.

    -Prelude
    My best code is written with the delete key.

  5. #5
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Oh. I remember a bug in Visual C++ 6.0. You have to add some code to a source code. Search MSDN for the article.

    Kuphryn

  6. #6
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    thanks you guys (and gals).
    C Code. C Code Run. Run Code Run... Please!

    "Love is like a blackhole, you fall into it... then you get ripped apart"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple question - getline()
    By QuietWhistler in forum C++ Programming
    Replies: 3
    Last Post: 01-24-2006, 01:16 PM
  2. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  3. getline question
    By Kings in forum C++ Programming
    Replies: 9
    Last Post: 01-20-2003, 01:01 PM
  4. STL container question
    By PJYelton in forum C++ Programming
    Replies: 8
    Last Post: 12-16-2002, 08:40 PM
  5. question about STL
    By free2run in forum C++ Programming
    Replies: 2
    Last Post: 12-16-2002, 12:12 PM