+ 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?
2 Answers
0
the way of create array is right?
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