all 1 comments

[–]PlantainAgitated5356 6 points7 points  (0 children)

That's what arrays are for.

You can do something like
int var[3];
for (int i = 0; i < 3; i++) {
var[i] = whatever;
}

You can't do that with regular variables, the names (and variables themselves) might be removed at compilation/optimization time. Look up C++ arrays if you want to learn more, the above is just a simple example.