fork download
  1. #include <stdio.h>
  2.  
  3. #define my_sizeof(type) ((char *)(&type + 1) - (char *)(&type))
  4.  
  5. int main() {
  6. int a;
  7. double b;
  8. char c;
  9.  
  10. printf("Size of int: %zu bytes\n", my_sizeof(a));
  11. printf("Size of double: %zu bytes\n", my_sizeof(b));
  12. printf("Size of char: %zu bytes\n", my_sizeof(c));
  13.  
  14. return 0;
  15. }
  16.  
Success #stdin #stdout 0.01s 5284KB
stdin
45
stdout
Size of int: 4 bytes
Size of double: 8 bytes
Size of char: 1 bytes