Suppose that we have a function:

void convert(std::istream& iss, std::ostream& oss)
{
std::string s;
// ...
// do something to feed s
// ...
oss << iss.rdbuf();
oss << s;
}

Normall, things go fine and we get os as the result of appending s into iss' content. But if iss is an totally empty istream, we will get an empty oss as well, no matter what is in s!!! Isn't it weird?

To circumvent this problem in this particular case, we switched the last two commands, so s will be added before iss' content and it will stay in oss when iss is empty. We tested it ;-)

HIGHLIGHTED POSTS

My wedding photos (17/09/08)

Friendly match - Austria 3 - 4 Netherlands (26/03/08)

5 days in Greece (Day 0 1 2 3 4 5) (15/03/08)

Lần đầu tiên trượt băng (28/02/08)

Uhrenmuseum Wien (24/02/08)

Wien Museum Karlsplatz Part 1 2 3 4 5 (17/02/08)

Slam Dunk (06/02/08)

Nem rán mừng xuân (05/02/08)

Comparisons between West and East's cultures (31/01/08)

Captain Tsubasa (27/01/08)

Bò xào, thật là đơn giản! (24/01/08)

Rambling in the center of Vienna (16/01/08)

The last night of the year 2007 in Vienna (01/01/08)

TOEFL Score (27/12/07)

Snowing in Vienna (16/11/07)

Locations of visitors to this page

page counter