Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 07-17-2005, 03:34 PM   #1 (permalink)
 
Junior Techie

Join Date: Jun 2005

Posts: 77

Tboltness

Send a message via AIM to Tboltness Send a message via Yahoo to Tboltness
Default C++ run issue

When I try to run something I make in C++, it won't work. The code has no errors or anything. I see the command prompt pop up for like a nanosecond but then it goes away and nothing happens. I'm using Dev-C++ to create, compile, and run.

TIA
Tboltness is offline  
Old 07-17-2005, 09:20 PM   #2 (permalink)
 
True Techie

Join Date: May 2005

Posts: 141

Something Sexy

Send a message via AIM to Something Sexy
Default

You need a break at the end of your code so it doesn't just run and close out right away. Make a dummy variable and toss a cin in there at the end, so the program will stay open until you hit enter.
Something Sexy is offline  
Old 07-17-2005, 11:24 PM   #3 (permalink)
 
Junior Techie

Join Date: Jun 2005

Posts: 77

Tboltness

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

Could you give me an example. I'm a C++ newb basically so an example would be of the utmost excellence.
Tboltness is offline  
Old 07-17-2005, 11:38 PM   #4 (permalink)
 
True Techie

Join Date: May 2005

Posts: 141

Something Sexy

Send a message via AIM to Something Sexy
Default

If your just trying to get some information on the screen and you wanna see what the program does, just toss this in at the end of the program, before the exit or return line:

char trash;
cin>>trash;


Then when the program runs, it will do whatever your program does up to the cin line, then just type in any character and hit enter and the program will end. Just do this for now until you learn more about programming and you can do something fancier later.
Something Sexy is offline  
Old 07-17-2005, 11:58 PM   #5 (permalink)
 
Junior Techie

Join Date: Jun 2005

Posts: 77

Tboltness

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

Wow, excellent! Thanks for helping me out. I just started taking it up 2 days ago so sill new. Thanks again.
Tboltness is offline  
Old 07-21-2005, 03:22 PM   #6 (permalink)
 
Banned

Join Date: Jul 2005

Posts: 80

Syn7ax 3rror

Send a message via AIM to Syn7ax 3rror
Default

You can also add this line of code before return 0:

system("Pause");

That's what I use.
Syn7ax 3rror 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