A
anugrah
While working with arrays I came across this piece of code:
int n;
cin>>n
int a[n];
And this works perfectly fine. However, I have been reading in many c+
+ textbooks that the size of an array should be known at compile time.
But the above code proves it to be wrong. Can anyone pls explain this
anomaly?
Moreover I have been declaring:
static int a[5];
And I am able to access elements of a[ ] indefinitely (i.e. with array
indexes even more than 5) without any sort of error. Please explain me
this phenomenon too.
int n;
cin>>n
int a[n];
And this works perfectly fine. However, I have been reading in many c+
+ textbooks that the size of an array should be known at compile time.
But the above code proves it to be wrong. Can anyone pls explain this
anomaly?
Moreover I have been declaring:
static int a[5];
And I am able to access elements of a[ ] indefinitely (i.e. with array
indexes even more than 5) without any sort of error. Please explain me
this phenomenon too.