int main()
{
int num;
printf("enter a number:");
scanf_s("%d", &num);
int array[num];//this line gives errors
for (int i = 0; i < num; i++)
{
array[i] = 1 + rand() % 100;
printf("%d ", array[i]);
}
}
Hi everyone I am having a constant problem in my c practice.This code runs well in online compiler but when ı try to run it with vs ı am getting a constant value and expression problem ı am not familiar with.I am a new coder so any help is appriciated.Thanks allready.(ı added a screen shot too in case you need one)
>Solution :
Microsoft compiler still did not implement C99 features like VLAs or flexible arrays.
You cant use:
int array[num];
as Microsoft does not support it. num has to be constant expression.