-1

I'm using this MACRO for debugging in C++ . Printing the variable name and value. Can anyone explain its working ?

#define watch(x) cout << (#x) << " is " << (x) << endl;
int t = 90;
watch(t);

// output is

t is 90

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
pankaj pundir
  • 377
  • 3
  • 6

1 Answers1

3

"stringizing" operator (#) converts macro parameters to string literals without expanding the parameter definition. It is used only with macros that take arguments.

GOVIND DIXIT
  • 1,748
  • 10
  • 27