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