DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Print Variable Macro

03.28.2006
| 5374 views |
  • submit to reddit
         A simple macro to print out a variable in c++
 Usage:
     int x = 5;
     string myString = "hello";
     prt(x);
     prt(myString);
 
 Output:
     x = '5'
     myString = 'hello'

#define prt(x) std::cout << #x " = '" << x << "'" << std::endl;