M
main()
Hi all,
I have the following code ,
#include <stdio.h>
#define f(a,b) a##b
#define g(a) #a
int main(void)
{
printf("%s\n",g(f(10,20)));
return 0;
}
Output that i got is
f(10,20)
But i expected
1020
My assumption was
1) first f(10,20) is replaced by 1020 , because of macro f(a,b)
concantenates its arguments
2) then g(a) macro replaces 1020 by a string literal "1020"
3) the output should be 1020
But why is f(10,20) not getting substituted.
I'm sure i'm missing something here.
Can someone explain me this program ?
Thanks for your time,
Yugi.
I have the following code ,
#include <stdio.h>
#define f(a,b) a##b
#define g(a) #a
int main(void)
{
printf("%s\n",g(f(10,20)));
return 0;
}
Output that i got is
f(10,20)
But i expected
1020
My assumption was
1) first f(10,20) is replaced by 1020 , because of macro f(a,b)
concantenates its arguments
2) then g(a) macro replaces 1020 by a string literal "1020"
3) the output should be 1020
But why is f(10,20) not getting substituted.
I'm sure i'm missing something here.
Can someone explain me this program ?
Thanks for your time,
Yugi.