Here is a short program I wrote
#include <iostream>
#define test0 "abc"
#define test1 "def"
#define concat(x,y) x##y
int main()
{
for (int i = 0 ; i < 2 ; ++i)
std::cout << concat(test,i) << std::endl;
return 0;
}
But for some reason it doesn't compile (it concatenates i
instead of i
value), is there a way I can concatenate i
's values instead of i
's name?
test1.cpp: In function ‘int main()’:
test1.cpp:8:1: error: ‘testi’ was not declared in this scope