fork download
  1. #include <stdio.h>
  2.  
  3. int main(void){
  4. int a=10;
  5. int *p=&a;
  6. char c='a';
  7. printf("Size of Int =%d\n",sizeof(a));
  8. printf("Size of Pointer =%d\n",sizeof(p));
  9. printf("Size of Char =%d\n",sizeof(c));
  10. printf("1.%d\n",sizeof(NULL)); // Returns size of Pointer
  11. printf("2.%d\n",sizeof*NULL); //Returns size of value pointer to by the Pointer. Same as Below.
  12. printf("3.%d\n",sizeof*(NULL)); //Returns size of value that is pointer to by the Pointer. Null Pointer points to char.
  13. printf("4.%d\n",sizeof((int*)1)); //Returns size of Pointer that is pointer to value 1
  14. printf("5.%d\n",sizeof(*(int*)1)); //Returns size of value pointed by the pointer. i.e Size of Integer 1.
  15.  
  16. printf("6.%d\n", sizeof*(1?NULL:(int*)1));
  17. printf("7.%d\n", sizeof*(0?NULL:(int*)1));
  18. return 0;
  19.  
  20. }
  21.  
Success #stdin #stdout 0s 4436KB
stdin
Standard input is empty
stdout
Size of Int =4
Size of Pointer =8
Size of Char =1
1.8
2.1
3.1
4.8
5.4
6.4
7.4