whats happening here

P

parag_paul

#include <stdio.h>
#define f(a,b) a##b
#define g(a) #a
#define h(a) g(a)

int main()
{
printf("%s\n",h(f(1,2)));
printf("%s\n",g(f(1,2)));
return 0;
}
 
B

bdsatish

#include <stdio.h>
#define f(a,b) a##b
#define g(a) #a
#define h(a) g(a)

int main()
{
printf("%s\n",h(f(1,2)));
printf("%s\n",g(f(1,2)));
return 0;
}

f(1,2) ==> 12 because ## is a concatenating operator, which treats its
inputs a strings. So 1 and 2 are concatenated to form 12

h(a) is simply #a where # is stringisizing operator. So h(12)
becomes the string "12"

Since g(a) is simply #a, the input argument f(1,2) is thrown out as if
it were a string.
 
P

parag_paul

f(1,2) ==> 12 because ## is a concatenating operator, which treats its
inputs a strings. So 1 and 2 are concatenated to form 12

h(a) is simply #a  where #  is stringisizing operator. So h(12)
becomes the string "12"

Since g(a) is simply #a, the input argument f(1,2) is thrown out as if
it were a string.

So what is the order of implemenation.
for h(f(1,2))

f(1,2)
happens first
and in the second case,
g(X)
happens first and then f(1,2)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top