fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main()
  5. {
  6. const std::string s{"foo"};
  7.  
  8. std::cout << "s: " << s << std::endl;
  9.  
  10. const auto sz{s.size()};
  11. std::cout << "s.size(): " << sz << std::endl;
  12.  
  13. const auto c_str{s.data()};
  14. const size_t sz_t{sizeof(c_str) / sizeof(c_str[0])};
  15. std::cout << sz_t << std::endl;
  16.  
  17. for (size_t i = 0; i < sz + 1; ++i)
  18. {
  19. std::cout << '#' << i << ' ' << static_cast<int>(*(s.c_str() + i)) << std::endl;
  20. }
  21.  
  22. int a[17];
  23. size_t n = sizeof(a)/sizeof(a[0]);
  24. std::cout << n << std::endl;
  25.  
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
s: foo
s.size(): 3
8
#0 102
#1 111
#2 111
#3 0
17