fork(1) download
  1. #define ARR_LEN_BY_MACRO(x) sizeof(x)/sizeof(*x)
  2. #include <iostream>
  3. #include <string>
  4.  
  5. int ARR_LEN_BY_FUNC(int *x)
  6. {
  7. return sizeof(x)/sizeof(*x);
  8. }
  9.  
  10.  
  11. int main()
  12. {
  13. int arr[5]={1,2,3,4,5};
  14. int m,f;
  15. m=ARR_LEN_BY_MACRO(arr);
  16. f=ARR_LEN_BY_FUNC(arr);
  17.  
  18. std::cout << m-f;
  19. }
  20.  
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
4