So, from what I've studied in C++, we cannot have arrays declared non-dynamically i.e. without the use of "new" keyword as it is against the C++ standard. I always thought that if not done this way, it would throw a compilation error or something and so didn't try it out myself (my bad). However, I now notice my peers using the following format of array declaration without any form of errors :
int n;
cin >> n;
int arr[n];
Now they have always been doing it this way as many of them were unfamiliar with dynamic allocation of memory or vectors and they seemingly never had an issue. Ran it on my machine for confirmation and it worked like a charm. So, my question is how does this work and if this works why bother with dynamic memory allocation? Are there some particular scenarios where this might fail badly?