View Full Version : C++, hello world?

Mar 29th, 2003, 09:47 PM
#include <iostream>

int main()
std::cout << "Hello world!\n";
return 0;

What's the problem with this code? It's driving me insane :( I try to compile it and I get the following error

c:/cpp/hello.cpp:7:2: Warning: no newline at end of file

Line 7 char 2 I guess that is, line 7 is the }

Josh Campbell
Mar 29th, 2003, 09:51 PM
For some reason you need a newline at the end of file to compile. Not an error, just a warning. Compilers are picky. Just press enter after the closing brace.

Mar 29th, 2003, 09:53 PM
:mad: That's the most stupid thing I've ever known lol Spent ages trying to figure it out too

:thumbsup: ta for that

Mar 29th, 2003, 09:59 PM
Bah, ok it's compiled into an *.exe now, but if I try to run it from dos, it's too big to fit in memory? :confused: so when I try to run it by clicking on the *.exe, it shows a popup saying that it's not a valid win32 file :( Is this just my compiler trying to wind me up and playing silly buggers with me, or is c++ not meant to work on windows?

Mar 29th, 2003, 11:11 PM
nm, fixed it. I needed the windows.h file thingy