Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

1 Answer
Nishtha Thakur

Here we will see how to define a macro called PRINT(x), and this will print whatever the value of x, passed as an argument.

To solve this problem, we will use the stringize operator. Using this operator the x is converted into string, then by calling the printf() function internally, the value of x will be printed. Let us see the example to get the better idea.

Example

#include <stdio.h>
#define PRINT(x) printf(#x)
int main () {
   PRINT(Hello);
   printf("\n");
   PRINT(26);
   printf("\n");
   PRINT(2.354721);
   printf("\n");
}

Output

Hello
26
2.354721

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.