Little questions about VLA

Правка en1, от xcx0902, 2024-03-20 15:16:42

As we all know, we can write codes like this in C++:

int main() {
    int n;
    cin >> n;
    int a[n];
    ...
}

But when the inputed n is too large, this program will crash.

So,

  1. Why it would crash?
  2. What is the lowest value n to make it crash?
  3. Why using malloc will not cause this problem?
Теги vla

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский xcx0902 2024-03-20 15:16:42 365 Initial revision (published)