Anfängerproblem:
-
Hallo,
ich hab ein Problem bei folgendem Testcode:
#include <iostream.h> int main(void) { cout << "Hallo Welt" << endl; return 0; }
Wenn ich es mit
g++ -o helloworld helloworld.cpp
kompilliere, erhalte ich die Fehlermeldung:
**
In file included from /usr/include/g++/backward/iostream.h:31,
from helloworld.cpp:1:
/usr/include/g++/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider usingone of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or<sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
**..sagt mir aber leider nicht viel. Ich hab mal versucht, das ".h" wegzulassen (ist ja soweit ich weiß deprecated), aber dann bekomme ich diese Fehlermeldung:
**
helloworld.cpp: In functionint main()': helloworld.cpp:5: error:
cout' undeclared (first use this function)
helloworld.cpp:5: error: (Each undeclared identifier is reported only once for
each function it appears in.)
helloworld.cpp:5: error: `endl' undeclared (first use this function)
**Kann mir da jemand weiterhelfen?
Danke, Andi
----------------------
Umgebung:
SuSE Linux 8.2
gcc version 3.3.4 (pre 3.3.5 20040809)
jEdit 4.1 final
-
Richtig wäre es so:
#include <iostream> int main() { std::cout << "Hallo Welt" << std::endl; return 0; }
oder so:
#include <iostream> using namespace std; int main() { cout << "Hallo Welt" << endl; return 0; }
Eine Erklärung findest du z.B. hier: http://www.cplusplus.com/doc/tutorial/tut5-2.html
-
Dieser Thread wurde von Moderator/in kingruedi aus dem Forum Linux/Unix in das Forum C++ verschoben.
Im Zweifelsfall bitte auch folgende Hinweise beachten:
C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?Dieses Posting wurde automatisch erzeugt.
-
ah, jetzt klappts. Danke!!