#x

(thing) by ariels Fri Dec 22 2000 at 9:21:46
The stringizing operator in the (ANSI C and C++) C preprocessor. It puts quotes around x (which should be a #define macro variable). So after
#define NL(x) (#x "\n")
we can say printf(NL(Look no newline!)); and have it print the string "Look no newline!\n".

This is occasionally useful (see ## for a piece of code based on production code I wrote that can use this).

If you want to stringize the contents of a macro (say, if you #define X 12 and you want to get the string "12"), you need to use the stringize macro macro hack.

Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.