0
Can you use the #define preprocessor to convert any value stored in a variable to string?
I came across the method of using #define preprocessor to convert any value to string in the following way... #define TO_STR(x) #x int main(){ printf("%s", TO_STR( 123 )) } Output: 123 I want to know if we can use the same method to convert a variable to a string...
1 Réponse
+ 1
Hi. Actually you cannot. Marcoses are used to modify source code before compiling, not in run time. If you try to pass a variable macros get it's name. You can use atoi function for this purpose.