Monday, March 22, 2010

61

Predict the output:
int main()
{
struct shark
{
int b;
#define selva() b
}s;
s.selva()=4;
printf("%d",s.b);
return 0;
}

Output:
4
Logic:
we know that macro processor is constant and replace with value while expanding.
selva() is equal to b.
when expanding the code ,s.selva is replaced by s.b .
so s.b=4.

0 comments:

Post a Comment