![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Write a C macro PRINT(x) which prints x
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("
"); PRINT(26); printf("
"); PRINT(2.354721); printf("
"); }
Output
Hello 26 2.354721
Advertisements