warum zur hölle kompiliert das?
-
#include <iostream> void f( int a ) { int feld[a]; for( int z = 0; z < a; ++z ) feld[z] = z; } int main() { int d; std::cin >> d; f(d); return 0; }
-
int feld[a]
ist C99. Sofern dein Compiler das zulässt, geht das. Reines C++ ist das aber net. Aber sonst seh ich nix weiter.
-
Welcher Compiler? Normalerweise müsste ein C++ Compiler einen Error ausspucken, dürfte nur unter einem C Compiler laufen.
-
Warum sollte denn da ein Fehler kommen?

-
effe_eichelt schrieb:
Warum sollte denn da ein Fehler kommen?

- a nicht konstant
- using namespace std; vergessen
-
Artchi schrieb:
Welcher Compiler? Normalerweise müsste ein C++ Compiler einen Error ausspucken, dürfte nur unter einem C Compiler laufen.
g++ (GCC) 3.3.5 (Debian 1:3.3.5-8ubuntu2)
Copyright (C) 2003 Free Software Foundation, Inc.@effe_eichelt:
weisst du was, was wir nicht wissen?@walli:
also, das 2. solltest du dir mal überlegen.p.s.: aaah, die weihnachtssmilies :xmas1: :xmas2: :xmas1: :xmas2: :xmas1:
-
Kompilier mal mit dem Flag -std=c++98
-
@effe_eichelt:
weisst du was, was wir nicht wissen?Nich das ich wüsste.

- a nicht konstant
Is das nich egal?
Also nach meiner inkompetenten Logik sollte der Code doch problemlos funktionieren.

-
effe_eichelt schrieb:
- a nicht konstant
Is das nich egal?
nö

-
7H3 N4C3R schrieb:
Kompilier mal mit dem Flag -std=c++98
geht :xmas2:
-
GCC hat das bei den Nonstandard Extensions gelistet (nonkonstante Arrays aufm Stack)
-
LordJaxom schrieb:
GCC hat das bei den Nonstandard Extensions gelistet (nonkonstante Arrays aufm Stack)
jepp, mit -ansi -pedantic kommt
testarray.cpp: In function
int f(int)': testarray.cpp:5: error: ISO C++ forbids variable-size arrayfeld'
paul@ubuntu:~/Desktop/c++$:xmas1:
-
Gott Effe du freak
goil^^
-