C++ Help Please

Status
Not open for further replies.

AndTwenTy10

In Runtime
Messages
183
Hey All, I downloaded Dev-C++ 4.9.9.2

http://www.cplusplus.com/doc/tutorial/tut1-1.html

I tried following that, But Everything I try to Compile keeps giving me errors... IM not sure how to fix them at all..

#include <iostream.h>

int main ()
{
cout << "Hello World!";
return 0;
}

Im trying to compile and run this program.. They said it's easy but it's not working for me.

Anyone know what I can do or..? Thanks.
 
Half of the code you typed is C, and the other half is C++. Here is what you need to print Hello World on the screen:

#include <iostream>
using namespace std;
int main()
{
cout<<"Hello World!";
system("pause");
return 0;
}

Without the system("pause"); it will close in one second in a win32 environment.
 
I Just tried that code, Compiled it and Ran it, It just opends a MS-Dos box, and said press anykey to continue.. Then shuts off.
 
Hmmm. Well my best bet would be to uninstall, and then reinstall the latest version. The code I sent you is correct, so I don't know why it wouldn't work. The last resort would be downloading Borland C++, after registering(it's free). I hope it works out...
 
Actually, you probably just need to flush the output buffer.
Code:
#include <iostream>
using namespace std;
int main()
{
    cout << "Hello World!" << endl;
    system("pause");
    return 0;
}
Whenever you're done writing to any form of file or buffer you need to flush it as soon as you're done. Which is what "endl" does.
 
If you want to print "Hello World" use the following code and compile:

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
cout << "Hello World\n\n";

system("PAUSE");
return EXIT_SUCCESS;
}
 
Maybe it's my program then, I tried everyone's code.. Same thing happends, MS-Dos box pops up and just sais "press anykey to continue"

Im using DEV-C++ 4.9.9.2
 
You probably have the wrong source code in the main so you are executing the wrong program, just double check that.
 
Status
Not open for further replies.
Back
Top Bottom