In C++ if I have
int a1, a2;
How do you print value of a1 by using a and 1 ?
If I am not clear, I want the program to interpret a some_symbol i as ai.
Like writing in$i.txt in cmd is taken as in0.txt, in1.txt for each i.
I remember reading exactly this in a book a number of months ago and I have occasionally re-searched.
I tried what I faintly remembered as $ but these only work in cmd I suppose.
Please help.
I think you mean “##”, it’s a preprocessor and it’s called concatenation
1 Like
“##” does concatenate but the argument won’t be expanded before concatenation
#define a(i) a##i
Then a(x) would just mean ax and not a1, a2, … and so on if x is 1, 2, …
Does this help? It was the first Google result for “preprocessor expand before concatenation”:
1 Like