Thread: What is this '#'?

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    175

    What is this '#'?

    Can anybody explain this??

    #define P( x ) printf( #x " = %d\n", x ) ;

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    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.

  3. #3
    Registered User glUser3f's Avatar
    Join Date
    Aug 2003
    Posts
    345
    Basically, in macros, #x is replaced with "x"

    So:
    Code:
    P(varname)
    Will become:
    Code:
    printf("varname" " = %d\n", varname);

Popular pages Recent additions subscribe to a feed