Can we do something like asking the user for the value of a variable, say "size" and then doing later in the code something like:
int array[size];
? If no, why?
CS50 Stack Exchange is a question and answer site for students of Harvard University's CS50. It only takes a minute to sign up.
Sign up to join this communityYes you can. Say you want an array of integers, you can do it like that:
printf("What is the length of the array?\n");
int n = GetInt();
int numbers[n];
for (int i = 0; i < n; i++)
{
numbers[i] = GetInt();
}