I am trying to figure out how to write a macro that will append value of a variable to a string. Here is a snippet of non working code but I am showing it so that I can explain what I want to do
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
#define DATA_RESPONCE_0 23
#define DATA_RESPONCE_1 24
#define DATA_RESPONCE_2 25
#define DATA_RESPONCE_3 26
#define my_macro(x) DATA_RESPONCE_##x
int main() {
int i = 0;
int k;
k = my_macro (i);
cout << k;
return 0;
}
In this case the macro is expanded as DATA_RESPONCE_i but I want it to be DATA_RESPONCE_0 so that 23 should be printed as a value of k.