Saturday, December 30, 2006

Puzzle

consider the following code fragment:

void fun()
{
}

int main()
{
int i=10;
fun();
printf("%d\n",i);
}

Now the task is to write something in function fun() such that main prints any other value than 10.... note that the value is to be printed in main()
think.....

Well the answer is as follows:
void fun()
{
#define printf(a,b) printf("20\n")
}
simple... isn't it :-)

No comments: