Reputation: 157
I am trying to create some 2d arrays according to user's input, and naming them with index value in a for loop. For example, if the user's input is 4, we create 4 2d arrays which names are "array1, array2, array3, array4". The reason why it's a 2d arrays because some string values are stored in them.
int main(int argc, char const *argv[]){
for (int i=0; i<4; i++){
char Cards + i [4][20]; //something like this?
}
return 0;
}
Upvotes: 0
Views: 84
Reputation: 213989
This is a common beginner misunderstanding. Variable names have absolutely no relation to user I/O nor do they exist in the linked executable. Names exists solely for the benefit of the programmer and nobody else. Therefore translating user input to variable names doesn't make any sense.
It rather sounds as if you should have a (possibly multi-dimensional) array with name meaningful to the programmer. You wouldn't name your dog "Dog1 because it's my first dog", now would you? Preferably name the array based on what you plan to store inside it. Then perhaps resize it depending on user input.
Upvotes: 1