Here we will see how to define a macro called PRINT(x), which will print any value of x passed as argument.
To solve this problem, we will use the stringize operator. Use this operator to convert x to a string, and then by calling the printf() function internally, the value of x will be printed. Let's look at an example to get a better idea.
#include#define PRINT(x) printf(#x) int main () { PRINT(Hello); printf(" "); PRINT(26); printf("
"); PRINT(2.354721); printf("
"); }
Hello 26 2.354721
The above is the detailed content of Write a C macro PRINT(x) which prints x. For more information, please follow other related articles on the PHP Chinese website!