// Program to implement sizeof operator #include <stdio.h> #define my_sizeof(type) (char *)(&type + 1)-(char *)(&type) int main(){ char x; printf("%d %d \n",(char *)(&x + 1), (char *)(&x)); printf("%d", my_sizeof(x)); getchar(); return 0; }
Can u please explain the program?? esp the macro part
Macro substitues the line and does the pointer arithematic for obtaining the size. Key point to know here is the difference between the normal arithematic operation and pointer arithematic....
Can u please explain the program?? esp the macro part
ReplyDeleteMacro substitues the line and does the pointer arithematic for obtaining the size. Key point to know here is the difference between the normal arithematic operation and pointer arithematic....
Delete