How the output of this code is 16?Code:main() { double d; printf("%d", (unsigned int)((double *)0+2)); }
How the output of this code is 16?Code:main() { double d; printf("%d", (unsigned int)((double *)0+2)); }
Last edited by GOGO1104; 09-28-2010 at 11:07 AM.
It's 16 due to pointer arithmetic. (double*)0+2 is the same as 0+2*sizeof(double).
bit∙hub [bit-huhb] n. A source and destination for information.
Didn't we just do this question in another thread?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.