I'm trying to create an array with dimension n in a function, i don't get why the compiler gives me this error:
error: variable-sized object may not be initialized
warning: excess elements in array initializer
The code is the following, the program isn't of course finished since I can't get this to work, and it gives me the same error in similar projects:
    #include <stdio.h>
#include <stdlib.h>
//given a number, find all binary numbers with that number of digits
int gen_num(int);
int main()
{
    int n;
    printf("Insert a number: ");
    scanf("%d",&n);
    gen_num(n);
    return 0;
}
int gen_num(int n){
    int num[n]={0};
    return 0;
}
If I try to not initialize in the declaration, but I for example try to ask the user to input some values it gives me the same error, since the array is created with dimension 0
Thanks in advance
 
     
    