Can anybody explain this??
#define P( x ) printf( #x " = %d\n", x ) ;
Can anybody explain this??
#define P( x ) printf( #x " = %d\n", x ) ;
It's called stringification. Here's a link: http://www.lns.cornell.edu/public/CO...p_1.html#SEC16
(It's amazing what a google search will turn up.)
If you understand what you're doing, you're not learning anything.
Basically, in macros, #x is replaced with "x"
So:
Will become:Code:P(varname)
Code:printf("varname" " = %d\n", varname);