Over a million developers have joined DZone.

Print Variable Macro

·
 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;

Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}