Advertisement
Guest User

Untitled

a guest
Mar 28th, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. string s = "ab";
  2. s[0] = '1';
  3. s[1] = '2';
  4. cout << s << "." << s[0] << "." << s[1] << "." << endl;
  5.  
  6. string ss = "";
  7. ss[0] = '1';
  8. ss[1] = '2';
  9. cout << ss << "." << ss[0] << "." << ss[1] << "." << endl;
  10.  
  11. string ss = "";
  12. ss[0] = '1';
  13. ss[1] = '2';
  14. cout << ss << "." << ss[0] << "." << ss[1] << "." << endl;
  15.  
  16. string ss = "";
  17. ss.at(0) = '1';
  18. ss.at(1) = '2';
  19. cout << ss << "." << ss[0] << "." << ss[1] << "." << endl;
  20.  
  21. $ ./cxx-test.exe
  22. libc++abi.dylib: terminate called throwing an exception
  23. Abort trap: 6
  24.  
  25. string ss = " "; // two blanks spaces
  26.  
  27. string ss;
  28. ss.resize(2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement