 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to print a variable name in C?
The following is an example to print variable name.
Example
#include <stdio.h> #define VariableName(name) #name int main() {    int name;    char ch;    printf("The variable name : %s", VariableName(name));    printf("
The variable name : %s", VariableName(ch));    return 0; }  Output
The variable name : name The variable name : ch
In the above program, the variable names are printed by defining the method before main()
#define VariableName(name) #name
Two variables of different datatypes are declared. By using the defined function, variable names are printed.
int name; char ch; printf("The variable name : %s", VariableName(name)); printf("
The variable name : %s", VariableName(ch));Advertisements
 