Results 1 to 5 of 5

Thread: getline with fstream

  1. #1

    Thread Starter
    Lively Member FantastichenEin's Avatar
    Join Date
    Mar 2000
    Location
    dairy
    Posts
    106

    getline with fstream

    std::string CFile::GetLine()
    {
    std::string line;
    std::getline(this->file, line, '/n'); // Error is here
    }

    I cannot get the above to work, any ideas why?
    this->file is an fstream.

    From the looks of the debug, it looks like getline won't accept an fstream?

    huge thanks
    ****

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    It's that '/n'. You need to use '\n'. Or better still, just leave it out. It knows to look for a newline.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Lively Member FantastichenEin's Avatar
    Join Date
    Mar 2000
    Location
    dairy
    Posts
    106

    parksie

    thanks for that Parksie.
    ****

  4. #4
    Lively Member
    Join Date
    Dec 2005
    Location
    UK
    Posts
    127

    Re: getline with fstream

    how do i stop the getline from returning /n ?

    any help would be cool
    regards
    John

  5. #5
    Fanatic Member twanvl's Avatar
    Join Date
    Dec 2001
    Posts
    771

    Re: getline with fstream

    Please, don't reply to 4 year old threads, start a new one!

    Getline does not return the \n in it's output, assuming '\n' is the delimter used for getline:
    If the delimiter is found, it is extracted but not stored.

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