fork(6) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6. string a;
  7. string b = " ";
  8.  
  9. a[0] = 'h';
  10. a[1] = 'i';
  11.  
  12. b[0] = 'h';
  13. b[1] = 'i';
  14.  
  15. cout << "a contains " << a << endl; //a does not work!
  16. cout << "b contains " << b << endl;
  17. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
a contains 
b contains hi