1 .#
If you want to include a macro parameter in a string, ansi c allows this. In the macro replacement section of the class function, # symbol is used as a preprocessing operator, which can convert the language symbol to the string. For example, if X is a macro parameter, # X can convert the parameter name into a corresponding string. This process is called stringizing ).
# Include <stdio. h> # define print (x) printf ("the value of print (" # X ") is % d \ n", x) int main () {print (5 + 20); Return 0 ;}
2 .##
# Operators can be used to replace class function macros. In addition, ## can be used to replace Class Object macros. This operator combines two language symbols into a single language symbol.
# Include <stdio. h> # define xname (n) x # N # define pxn (n) printf ("X" # N "= % d \ n", X # N) int main (void) {// int xname (1) = 12; // int X1 = 12; // pxn (1 ); // printf ("X1 = % d \ n", X1); int I = 0; for (I = 0; I <10; I ++) {int xname (I) = I; pxn (I);} return 0 ;}