+ 1

Need help with tab :(

Here is my code int main () int n; int a; int i; cin>>n; int tab[n]; for (i=0; i<n; i++){ cin>>a; tab[i]=a; } My problem is that i cannot use variable as number of intergients in tab, in code::blocks it works and I have only warning, but other compilers give me error. Is there other way to use variable in number used in declaring tab?

18th Jun 2016, 7:18 AM
Alicja Kluczek
Alicja Kluczek - avatar
3 Respostas
0
the way of create array is right?
18th Jun 2016, 8:40 AM
苏琦
苏琦 - avatar
0
int main () { int n,i; cin>>n; int tab[n]; for (i=0; i<n; i++){ cin>>tab[i]; } return 0; } try this,it should work,don't know why it wasn't working for you
18th Jun 2016, 8:53 AM
Tushar Purang