Results 1 to 2 of 2

Thread: C Program Logic Question

  1. #1
    Junior Member
    Join Date
    Feb 2007
    Answers
    7

    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


  2. #2
    Junior Member
    Join Date
    Aug 2007
    Answers
    4

    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
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact