View Full Version : What I'm I doing wrong?
Lord Winter
03-10-2007, 19:18
I've been trying to learn C++ and I've started with the clasic hello world program just as a test. But every time I try to run it the dos type window appears just for a fraction of a second. My code:
// hello world program
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0; }
Does anyone see anything obvious?
Reenk Roink
03-10-2007, 19:24
Your code looks OK, I really don't see the problem. :huh: Try putting the end curly on the next line like this:
// hello world program
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
If that doesn't work, it may not be the code's fault but something else.
Good luck learning by the way, I'm learning it too (and having a tough time in class).
Lord Winter
03-10-2007, 20:01
:gah2: That didn't work.
Good luck to you to, I've been trying off and on for about a year and now I'm trying to make a solid attempt. What compiler do you use?
Why you dont start from crash again?
Reenk Roink
03-10-2007, 20:22
:gah2: That didn't work.
Good luck to you to, I've been trying off and on for about a year and now I'm trying to make a solid attempt. What compiler do you use?
I use the compiler that comes with Visual Studio 2005 (school software) but I don't know specifically.
Also, one last thing. Caius Flaminius is right, just try again, and try adding an "endl;" after your cout like:
cout << "Hello World!" << endl;
Lord Winter
03-10-2007, 21:46
found the problem, the program wasn't stoping at the end so it just closed. I fixed it by adding: system (pause) to the end. Thanks for your help. :bow:
vBulletin® v3.7.1, Copyright ©2000-2025, Jelsoft Enterprises Ltd.