doubt in sizeof implementation
- by aks
Below is the program to find the size of a structure without using sizeof operator:
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;
}
My doubt is:
Why is typecasting to char * required?
If I don't use the char* pointer, the output is 1 - WHY?