fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. struct player {
  5. std::string name;
  6. };
  7.  
  8.  
  9. int main()
  10. {
  11. std::cout << sizeof(player) << '\n';
  12. player p;
  13. p.name.resize(10000);
  14. std::cout << "The number of characters in p.name is " << p.name.size() <<
  15. "\nbut sizeof(player) is still " << sizeof(p);
  16. }
Success #stdin #stdout 0s 4500KB
stdin
Standard input is empty
stdout
32
The number of characters in p.name is 10000
but sizeof(player) is still 32