fork(1) download
  1. #include <cstdio>
  2.  
  3. template <typename T>
  4. void printsize(T* t, const char* type)
  5. {
  6. std::printf("Calculated size of %s array is %u\n", type, sizeof(t) / sizeof(t[0])) ;
  7. }
  8.  
  9. int main(void) {
  10. char carray[10];
  11. int iarray[3];
  12.  
  13. printsize(carray, "char[10]" ) ;
  14. printsize(iarray, "int[3]") ;
  15. }
  16.  
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
Calculated size of char[10] array is 4
Calculated size of int[3] array is 1