Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 07-05-2005, 12:16 AM   #1 (permalink)
 
True Techie

Join Date: Oct 2004

Posts: 183

AndTwenTy10

Send a message via AIM to AndTwenTy10 Send a message via Yahoo to AndTwenTy10
Default C++ Help Please

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.
AndTwenTy10 is offline  
Old 07-05-2005, 04:02 AM   #2 (permalink)
 
Newb Techie

Join Date: Jul 2005

Posts: 9

tspier2

Send a message via Yahoo to tspier2
Default

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.
tspier2 is offline  
Old 07-05-2005, 04:08 AM   #3 (permalink)
 
True Techie

Join Date: Oct 2004

Posts: 183

AndTwenTy10

Send a message via AIM to AndTwenTy10 Send a message via Yahoo to AndTwenTy10
Default

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.
AndTwenTy10 is offline  
Old 07-05-2005, 05:47 AM   #4 (permalink)
 
Newb Techie

Join Date: Jul 2005

Posts: 9

tspier2

Send a message via Yahoo to tspier2
Default

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...
tspier2 is offline  
Old 07-05-2005, 09:37 AM   #5 (permalink)
 
Ultra Techie

Join Date: Sep 2003

Location: Bamberg, Germany

Posts: 549

Iron_Cross

Send a message via ICQ to Iron_Cross Send a message via MSN to Iron_Cross Send a message via Yahoo to Iron_Cross
Default

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.
__________________

See today\'s Penny-Arcade!(May contain foul lanuage)
Pain is weakness leaving the body.

PM Me for my MSN
Iron_Cross is offline  
Old 07-05-2005, 12:27 PM   #6 (permalink)
Chase's Avatar
 
CECS Major

Join Date: Jul 2005

Location: Louisville, KY

Posts: 387

Chase is on a distinguished road

Send a message via MSN to Chase Send a message via Yahoo to Chase Send a message via Skype™ to Chase
Default

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;
}
Chase is offline  
Old 07-05-2005, 02:20 PM   #7 (permalink)
 
True Techie

Join Date: Oct 2004

Posts: 183

AndTwenTy10

Send a message via AIM to AndTwenTy10 Send a message via Yahoo to AndTwenTy10
Default

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
AndTwenTy10 is offline  
Old 07-05-2005, 02:33 PM   #8 (permalink)
Chase's Avatar
 
CECS Major

Join Date: Jul 2005

Location: Louisville, KY

Posts: 387

Chase is on a distinguished road

Send a message via MSN to Chase Send a message via Yahoo to Chase Send a message via Skype™ to Chase
Default

Have you tried reinstalling it?
Chase is offline  
Old 07-05-2005, 04:25 PM   #9 (permalink)
 
True Techie

Join Date: Oct 2004

Posts: 183

AndTwenTy10

Send a message via AIM to AndTwenTy10 Send a message via Yahoo to AndTwenTy10
Default

Yeah, I tried. Same stuff..
AndTwenTy10 is offline  
Old 07-05-2005, 04:25 PM   #10 (permalink)
 
Super Techie

Join Date: Jan 2005

Posts: 295

gab00n

Default

You probably have the wrong source code in the main so you are executing the wrong program, just double check that.
__________________
\"Today\'s scientists have substituted mathematics for experiments, and they wander off through equation after equation, and eventually build a structure which has no relation to reality.\" Nikola Tesla
gab00n is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On