fork download
  1. #include <iostream>
  2.  
  3. // naive approach, don't do that
  4. int myarraysize(char s[])
  5. {
  6. return sizeof(s);
  7. }
  8.  
  9. int main ()
  10. {
  11. char c[] = "hello";
  12.  
  13. std::cout << sizeof(c) << " vs " << myarraysize(c) << std::endl;
  14. return 0;
  15. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
6 vs 4