fork(1) download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <fstream>
  4.  
  5. std::stringstream fs("AAAAAAA");
  6. int buffSize = 100;
  7. int bytesRead = 0;
  8. char* buffer = new char[buffSize]{};
  9.  
  10. int main()
  11. {
  12. fs.write("hello", 5);
  13. fs.seekp(0, std::ios::beg);
  14.  
  15. fs.read(buffer, buffSize);
  16. /* ==== */ fs.clear(); /* ==== */
  17. bytesRead = fs.gcount();
  18.  
  19. std::cout << buffer << "\n";
  20.  
  21. fs.seekp(1, std::ios::beg);
  22. fs.write("E", 1);
  23.  
  24. std::cout << fs.str();
  25. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
helloAA
hElloAA