Thread: Quick std::string.getline() question.

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    85

    Question Quick string::getline() question.

    What does string::getline() do with the '\n' or other delimiter? Does it discard it? Leave it in the stream? Append it to the end of the string it reads in? Put it in it's hat and call it macaroni?

    Thanks for the info.
    Last edited by A10; 10-31-2007 at 06:47 PM. Reason: Typo(s)

  2. #2
    Registered User mikeman118's Avatar
    Join Date
    Aug 2007
    Posts
    183
    I'm pretty sure that it does nothing with it. It just reads until it finds the delimiting character, and then stops - it doesn't read it, no.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    It discards the delimiter.

    >> I'm pretty sure that it does nothing with it. It just reads until it finds the delimiting character, and then stops - it doesn't read it, no.

    This is not correct. It reads until it finds the delimiter and adds the characters it finds to the string. It does not add the delimiter to the string, but it does remove it from the input buffer. The next time you read from the buffer the delimiter will not be there.

  4. #4
    Registered User
    Join Date
    Nov 2006
    Posts
    85

    Cool

    Quote Originally Posted by Daved View Post
    It discards the delimiter.

    The next time you read from the buffer the delimiter will not be there.

    Thanks that's exactly what I needed to know.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Very quick math question
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 10-26-2005, 11:05 PM
  2. very quick question.
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 07-24-2002, 03:48 AM
  3. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 04:44 AM
  4. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 11:04 AM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM