Flushing a stringstream

This is a discussion on Flushing a stringstream within the C++ Programming forums, part of the General Programming Boards category; Basically, when print something to the stringstream and later extract it it still remains in the stringstream. I want to ...

  1. #1
    Eibro_Guest
    Guest

    Flushing a stringstream

    Basically, when print something to the stringstream and later extract it it still remains in the stringstream. I want to flush the stream so the next insertion I make will only be extracted.

    stringstream::flush() isn't working. Please help!

    Code:
       std::ifstream keywords("keywords.txt", std::ios::in);
       if (keywords.is_open())
       {
          std::string line, fmtkey;
          std::stringstream format;
          while (std::getline(keywords, line))
          {  
             format << ' ' << line << ' ';
             format >> fmtkey;
    
             // How do I flush the entire stream? Contents from last insertion/extraction still remain
    
             format << "<layer class=\"keyword\"> " << line << " </layer>";
             format >> line;
    
             special.push_back(stringpair(fmtkey, line));
          }
          keywords.close();
       }

  2. #2
    Eibro_Guest
    Guest
    Nevermind, I figured it out.
    Thanks Eibro.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stringstream problem
    By black_spot1984 in forum C++ Programming
    Replies: 5
    Last Post: 10-28-2008, 05:45 PM
  2. stringstream problem
    By black_spot1984 in forum C Programming
    Replies: 3
    Last Post: 10-28-2008, 04:09 PM
  3. stringstream clear
    By misterowakka in forum C++ Programming
    Replies: 3
    Last Post: 01-01-2008, 12:03 PM
  4. Socket: send stringstream
    By crisis in forum C++ Programming
    Replies: 5
    Last Post: 11-22-2007, 09:50 AM
  5. Length of a stringstream
    By nickname_changed in forum C++ Programming
    Replies: 1
    Last Post: 10-24-2003, 07:30 PM

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