vendredi 2 juillet 2021

C++ supporting user entered array size on stack memory [duplicate]

I was surprised to see that below code works in C++.

int n;
cin >> n;
int arr[n];

which is violating most of the information available on internet in this context, that, array size should be compile time known. Is the above feature/behavior is universally rolled out and accepted, or it is just compiler dependent or C++ language version dependent?

Aucun commentaire:

Enregistrer un commentaire