I'm learning C and I wrote a simple program displaying first n numbers of fibonacci sequence, where n is user input. VS Code shows error when I declare an array with length n ("expression must have a constant value"). The program compiles and runs just fine, but the line and file highlighted in red is quite annoying. Am i doing something wrong, or is it a problem with VS Code? Program:
#include<stdio.h>
#include<stdlib.h>
int main() {
printf("Ile liczb fibonacciego: ");
int n;
scanf("%d", &n);
int fibo[n];
for (int i = 0; i < n && i < 2; i++)
fibo[i] = i;
for (int i = 2; i < n; i++)
fibo[i] = fibo[i-1] + fibo[i-2];
for (int i = 0; i < n; i++)
printf("%d ", fibo[i]);
return 0;
}