2014-09-19

How would you find the size of structure without using sizeof()?

Try using pointers
struct MyStruct
{
int i;
int j;
};
int main()
{
struct MyStruct *p=0;
int size = ((char*)(p+1))-((char*)p);
printf("\nSIZE : [%d]\nSIZE : [%d]\n", size);
return 0;
}

0 comments:

Post a Comment

Tools & Plugins

Blog Archive