fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <iterator>
  5. using namespace std;
  6.  
  7. int main() {
  8. string prepinac="Hello", file="World";
  9. char obsah[]="Te\0st";
  10. string sprava = prepinac+"\n"+file+"\n"+obsah;
  11. cout <<sprava<<endl<<sprava.length()<<endl<<"---"<<endl;
  12. string full = prepinac+"\n"+file+"\n";
  13. size_t start= full.length();
  14. full.resize(start+5);
  15. copy(obsah, obsah+5, &full[start]);
  16. cout <<full<<endl<<full.length()<<endl<<"---"<<endl;
  17. string full2 = prepinac+"\n"+file+"\n";
  18. copy(obsah, obsah+5, back_inserter<string>(full2));
  19. cout <<full2<<endl<<full2.length()<<endl<<"---"<<endl;
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 3416KB
stdin
Standard input is empty
stdout
Hello
World
Te
14
---
Hello
World
Test
17
---
Hello
World
Test
17
---