Trying to assign a variable as the length of an array in C
I'm trying to get n specific number of values from the user, to do this I
went the easy way and asked the user to enter a specific number of values
to be entered. This amount of values is saved in a variable, for example
"x":
int x;
printf("Enter the number of values to be entered: ");
scanf("%d", &x);
int array[x];
So when I try to run the code I get the following message:
Constant Expression Required
Why does this happens? How could I fix it?
No comments:
Post a Comment