fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main () {
  7. string str1 = "Hello";
  8. string str2 = "World";
  9. string str3;
  10. int len ;
  11.  
  12. // copy str1 into str3
  13. str3 = str1;
  14. cout << "str3 : " << str3 << endl;
  15.  
  16. // concatenates str1 and str2
  17. str3 = str1 + str2;
  18. cout << "str1 + str2 : " << str3 << endl;
  19.  
  20. // total lenghth of str3 after concatenation
  21. len = str3.size();
  22. cout << "str3.size() : " << len << endl;
  23.  
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 16056KB
stdin
Standard input is empty
stdout
str3 : Hello
str1 + str2 : HelloWorld
str3.size() :  10