how to make macro replacement text into a string in C / C++

Solution 1:

You have to do another pass. Typically:

#include <iostream>   

#define NUMBER      2.847

#define STRING(a)   #a
#define XSTRING(a)  STRING(a)

int main() {
   std::cout << XSTRING(NUMBER) << '\n';
}