Array mit nicht konstanter Größe: Warum funktioniert das überhaupt? [Duplikat]
Diese Frage hat hier bereits eine Antwort:
C ++: Warum funktioniert int array [size]? 3 Antworten#include <iostream>
using namespace std;
int main(){
int n;
cout<<"Enter the size :";
cin>>n;
int array[n]; // I've worked some outputs and it works
return 0;
}
Ist das eine Art dynamische Zuordnung?
Warum gibt es nicht einmal einen Fehler, wenn 'n' eine "const" ist?
Auch schriftlichcout << array[n+5];
führt nicht zu einer Kompilierungszeit oder einem Laufzeitfehler.
Ich benutze Dev-C ++.