Yahoo Interview Question
Software Engineer / Developers#define My_Sizeof(type) ((char*)((type*)0 +1) - (char*)(type*)0)
This works, I have checked on VC++ compiler
what something like this
int main()
{
char a;
int n;
if(n=((char*)(&a+1)-(char*)&a))
if(n==4)
printf("it is integer");
else if(n==1)
printf("it is char");
// and so on
return 0;
}
its working dear
The question explains why Yahoo had to use Bing to power its search results and why no one uses Yahoo mail.
I see your point. I'm surprised by a lot of these ridiculous Yahoo interview questions.
#define sizeof_type( type ) (size_t)((type*)1000 + 1 )-(size_t)((type*)1000)
- Anonymous September 13, 2010