fork(15) download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <iterator>
  6.  
  7. int main(){
  8. std::stringstream src("....");
  9. std::vector<char> dest;
  10. // for a bit of efficiency
  11. std::streampos beg = src.tellg();
  12. src.seekg(0, std::ios_base::end);
  13. std::streampos end = src.tellg();
  14. src.seekg(0, std::ios_base::beg);
  15. dest.reserve(end - beg);
  16.  
  17. dest.assign(std::istreambuf_iterator<char>(src), std::istreambuf_iterator<char>());
  18.  
  19. std::copy(dest.begin(), dest.end(), std::ostream_iterator<char>(std::cout));
  20. }
  21.  
Success #stdin #stdout 0.02s 2860KB
stdin
Standard input is empty
stdout
....