-1

Yesterday I was helping a friend w/ some C progamming and he used to declare arrays in this way:

/*includes*/
int i; 
scanf("%d",&i);
int array[i];

I don't think it's a legit way but the compilers gave no error... So is it right/possible to declare an array or there could be any problem with that kind of declaration?

FedeMITIC
  • 93
  • 1
  • 5

1 Answers1

0

As stated in (How do compilers treat variable length arrays) in the C99 version of the C standard, variable length arrays are permitted. However, they are not permitted in any version of C++.

Community
  • 1
  • 1
Pedram
  • 224
  • 1
  • 3
  • 12
  • Ok that's why i got confused: i l'am studying c++ right now and when I studied C I never saw that kind of declaration since I was used to use dynamic lists of elements... Ty for the answer – FedeMITIC May 22 '14 at 10:54