I want to create an variable-length array. Here is my code:
#include <stdio.h>
int main (void)
{
int n,i, response;
while(true){
printf("Enter the number of responses:");
scanf("%i",&n);
if(n<1){
printf("Wrong number\n");
}
else
break;
}
int raiting[n];
}
Here I assign the value, that user enter, to the variable n
and the value should be greater than one.
But it give me errors:
1)expected constant expression
2)cannot allocate an array of constant size 0
3)'raiting unknown size'
I am using Visual Studio.
How can I fix that? Why it's wrong?