mardi 28 mars 2017

Why does variable length array fail initialization in C++

I am trying to create an array (without dynamic allocation and vectors)

int main(){
int n;
scanf("%d",&n)
int a[n]; // This works and compiles.
int a[n] = {} // This does not work
}

Why is that compilation works with declaration but fails with initialization, why?

Aucun commentaire:

Enregistrer un commentaire