Quick std::string.getline() question.

This is a discussion on Quick std::string.getline() question. within the C++ Programming forums, part of the General Programming Boards category; What does string::getline() do with the '\n' or other delimiter? Does it discard it? Leave it in the stream? Append ...

  1. #1
    A10
    A10 is offline
    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 07: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,344
    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
    A10
    A10 is offline
    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-27-2005, 12:05 AM
  2. very quick question.
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 07-24-2002, 04:48 AM
  3. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 05:44 AM
  4. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 12:04 PM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 06:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21