Home > Back-end >  ım having problem with constant concept in c
ım having problem with constant concept in c

Time:12-16

int main()
{
    int num;
    printf("enter a number:");
    scanf_s("%d", &num);
    int array[num];//this line gives errors
}

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)

CodePudding user response:

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.

  •  Tags:  
  • c
  • Related