Create function to substitute value in string with macro - C Preprocessor

C examples for Preprocessor:Macro

Description

Create function to substitute value in string with macro

Demo Code

#include <stdio.h>
#define PSQR(x) printf("The square of " #x " is %d.\n",((x)*(x)))

int main(void){
    int y = 5;/*  w ww. j a  v a 2 s . co m*/
    
    PSQR(y);
    PSQR(2 + 4);
    
    return 0;
}

Result


Related Tutorials