PDA

View Full Version : C++, hello world?



Nightfire
03-29-2003, 10: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
03-29-2003, 10: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.

Nightfire
03-29-2003, 10: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

Nightfire
03-29-2003, 10: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?

Nightfire
03-30-2003, 12:11 AM
nm, fixed it. I needed the windows.h file thingy