I have gone through sizeof operator equivalent.
size_t size = (size_t)(1 + ((X*)0));
But could not able to understand what is the meaning of (int*)0 or (int*)1000.
What does it tell to the compiler? And why one is added to them? Could you please elaborate it.
(int *)0means “treat 0 as the address of an integer”. Adding one to this obtains the address of the “next” integer in memory. Converting the result back to an integer therefore gives you the size of an integer.However, this relies on undefined behaviour, so you shouldn’t use it.