Why is it allowed to declare an automatic array with size depending on user input? [duplicate]
问题 This question already has answers here : Why aren't variable-length arrays part of the C++ standard? (12 answers) Closed last year . I'm using MinGW to compile for C++11 and I found out that this doesn't throw an error: int S; cin>>S; char array[S]; While this does ("storage size of 'array' isn't known"): char array[]; To me, the size is also unknown in the first case, as it depends on what the user input is. As far as I knew, automatic arrays are allocated at compile time in stack memory. So