I cannot believe this, this dimension won't be known until runtime, but it works.
1 2 3 4 5 6 7 8 9 10 11 12 13
|
#include <iostream>
using namespace std;
int main() {
int i;
cin>>i;
const int ci=i;
int ai[ci];
cin>>ai[0]>>ai[1];
cout<<i<<endl;
cout<<ai[0]<<ai[1];
return 0;
}
| |
why? who can explain this? a false pretended const also work?
Last edited on
really? I use GCC
and even if I input 1 for i, I can still input two values for ai[0], and ai[1] which should not be existing.
funny! I am confused!
Last edited on
With GCC, use -pedantic
to make it report when it's using language extensions.
Last edited on
Thanks ,your information is very useful!