fork(1) download
  1. #include <iostream>
  2. #include <sstream>
  3.  
  4. int main(int argc, const char * argv[])
  5. {
  6. std::stringstream a;
  7. std::stringstream b;
  8. std::stringstream c;
  9. std::stringstream out;
  10.  
  11. a << "abc";
  12. b << "";
  13. c << "xyz";
  14.  
  15. out << a.rdbuf();
  16. printf("after A out.tellp = %qd\n", (int64_t)out.tellp());
  17.  
  18. out << b.rdbuf();
  19. if( ! out.good() )
  20. {
  21. std::cout<< "It is not good!!!" << std::endl;
  22. out.clear();
  23. }
  24. printf("after B out.tellp = %qd\n", (int64_t)out.tellp());
  25.  
  26. out << c.rdbuf();
  27. printf("after C out.tellp = %qd\n", (int64_t)out.tellp());
  28.  
  29. std::cout << out.rdbuf() << std::endl;
  30.  
  31. return 0;
  32. }
Success #stdin #stdout 0s 4476KB
stdin
Standard input is empty
stdout
after A out.tellp = 3
It is not good!!!
after B out.tellp = 3
after C out.tellp = 6
abcxyz