Is there a way to evaluate an expression before stringification in c?
example:
#define stringify(x) #x
...
const char * thestring = stringify( 10 *
Preprocessor macros are run before the compiler. It is, by definition, not possible to do exactly what you'retrying to do.
To convert a number into a string at runtime, call the itoa
function, like this:
char thestring[8];
itoa(10 * 50, thestring, 10);
Note that this code declares thestring
as an array, not a pointer. For more information, read about memory management in C.