Code:
#include <stdio.h>
#define puts "%s C preprocessor"
int main()
{
printf(puts, puts);
return 0;
}
Output:
%s C preprocessor C preprocessor
Can anyone explain me the logic behind this output?
I tried to solve it,but I didn't get the proper explanation through my friends. If anyone can explain me ,it'll be very helpful.
The macro let to (code after linker):
int main
{
printf("%s C preprocessor", "%s C preprocessor");
return 0;
}
printf
works like:
The output is then
%s C preprocessor C preprocessor