Home / C Programming / C Preprocessor :: Discussion

Discussion :: C Preprocessor

  1. The output of the following program is:

    #define f(g,g2) g##g2

    void main()

    {

    int var12=100;

    printf("%d", f(var,12));

    }

  2. A.

     Syntax error

    B.

     Runtime error

    C.

     g##g2

    D.

     100

    E.

     10012

    View Answer

    Workspace

    Answer : Option D

    Explanation :

    ## is token pasting operator which simply combines all the parameters of macro into one variable.
    So, in f(var, 12), var and 12 combines to form var12 and replaces the f(var, 12) and hence the output is 100.


Be The First To Comment