-
Junior Member
C Program Logic Question
#define f(g1,g2) g1##g2
main()
{
int var12=100;
printf("%d",f(var,12));
}
this prints the output 100. and if i change the value in f(var,12) as f(var,13) a error is coming and if i delete # then also error is coming i cant understand give a brief explanation
#define f(g1,g2) g1##g2
main()
{
int var12=100;
printf("%d",f(var,12));
}
this prints the output 100. and if i change the value in f(var,12) as f(var,13) a error is coming and if i delete # then also error is coming I cant understand give a brief explanation
-
Junior Member
Re: C Program Logic Question
## is String concatenation operator. This will concatenates two values in that Macro.
Here Var12=100.
In Macro f(g1,g2) is g1##g2.
So If f(var,12) then it is var12 so Answer is 100.
If we put f(var,13) then it is var13, which is not declared.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules