Is it possible to create a list of variables with a parameter in the name? Something like this:
for(n=0; n< val; n++)
int var\'n\'=0;
Usually, no.
Variables names must be fixed at compile-time. They cannot depend on run-time input. So if the n
in your example is input (say, from the user), what you want cannot be done.
If you know n
statically, you could do tricks with the preprocessor, or templates, or both, but you probably don't want to: How would you get to use your n
variables?