getline - refresher

Discussion in 'C++' started by brekehan8@gmail.com, Apr 9, 2009.

  1. Guest

    Been a long long time since I did basic file parsing. See what working
    with your employers libraries does to you?!

    I am using fstream::getline. I cannot remember, if I attempt to read a
    line that is longer than my provided buffer size, will fstream::fail()
    return true, and therefore fstream::good() return false?

    Is there any other way to parse a line of a file at a time directly
    into a string or stringstream, since it ends up there anyway in my
    code?
     
    , Apr 9, 2009
    #1
    1. Advertising

  2. Guest

    Or heck, I would even be happy if I could read the entire file
    directly into a stringstream, because I am going to use the extractor
    and string's find methods now that I think about it.
     
    , Apr 9, 2009
    #2
    1. Advertising

  3. Jerry Coffin Guest

    In article <9a9179e2-2e3e-4e11-97af-e5cacf7c7e80
    @k2g2000yql.googlegroups.com>, says...
    >
    > Or heck, I would even be happy if I could read the entire file
    > directly into a stringstream, because I am going to use the extractor
    > and string's find methods now that I think about it.


    For that, you can use something like:

    std::stringstream buffer;

    buffer << input_stream.rdbuf();

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.
     
    Jerry Coffin, Apr 9, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John
    Replies:
    10
    Views:
    10,065
    Buster Copley
    Jul 14, 2003
  2. richard
    Replies:
    6
    Views:
    344
    Jonathan N. Little
    Sep 18, 2006
  3. capes
    Replies:
    0
    Views:
    383
    capes
    Sep 9, 2005
  4. Good refresher site

    , Mar 12, 2007, in forum: C Programming
    Replies:
    11
    Views:
    533
    Keith Thompson
    Mar 13, 2007
  5. Niall 84

    Refresher questions in C/C++

    Niall 84, Oct 29, 2008, in forum: C Programming
    Replies:
    3
    Views:
    323
    Default User
    Oct 29, 2008
Loading...

Share This Page