Prepare for your Next Interview
This is a discussion on C Program Logic Question within the C and C++ forums, part of the Software Development category; #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(...
|
|||
|
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 |
| Sponsored Links |
|
|||
|
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. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Knowledge about Program ID in Cobol program | RyanJames | MainFrame | 2 | 02-14-2008 09:32 AM |
| Can anyone write this Matching Logic? | zyxwv | MainFrame | 0 | 05-16-2007 07:06 PM |
| what is the logic behind this ? | psuresh1982 | Brainteasers | 7 | 02-05-2007 03:38 AM |
| Where lies the flaw in the logic? | psuresh1982 | Brainteasers | 1 | 11-17-2006 02:00 AM |
| Apply Logic to get the number | Bessie | Brainteasers | 2 | 08-25-2006 04:24 PM |