954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Running My Program

OK, I' m just starting C++, I've written a few really simple programs, like calculations and displaying stuff etc. I've used Borland's Turbo C++ 4.5 and DEV C++ to write and compile few of theses progams, I run a Windows XP home OS. The Question I have is: Why, whenever I click on one of the programs I've Compiled with DEV C++ they only flash on screen for a short while then close, without showing what they are supposed to? I haven't tried the ones compiled with Borland C++ on the Xp machine yet.

I know what I tell some of them to do are happening because I glimpsed the ones with the writings that I have written on screen but they close by themselves, the ones I have written that require use inputs wait until the info is entered then close, could anyone give me advice regarding what could be the cause of this.

I've Written a few of these programs using Borland Turbo C++ on an ME system and they run until I close them, I think there is a bit of a difference between DEV C++ and Borland C++, source codes I have written in Dev C++ do not compile on Borland C++ - they return errors and vice versa. Could this be an issue with standards?


This might sound a bit odd to the more experienced people but this is kinda bothering me a bit.

Lynqu2
Newbie Poster
7 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

To make the output window stay you can make the program wait for the user to press a key, so that you get to see the output of your program.

If using C++ you can place cin.get( ) at the end of your program, before return 0.

If using C, you can place getchar( ) at the end of your program, before return 0.

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

I think that Dev C++ follows the standard better, since it really uses a very common open source compiler. A program should close unless you make it wait within the code. Anything else is added by the IDE and is not standard.

Your version of Borland C++ is very old. Also Borland has a long history of straying from the standards. I am really surprised they are still around.

Ene Uran
Posting Virtuoso
1,723 posts since Aug 2005
Reputation Points: 625
Solved Threads: 213
 

"system("PAUSE");" can make the console window stay until you press any key.

Looben
Newbie Poster
12 posts since Dec 2006
Reputation Points: 10
Solved Threads: 1
 

I think that Dev C++ follows the standard better, since it really uses a very common open source compiler. A program should close unless you make it wait within the code. Anything else is added by the IDE and is not standard.

Your version of Borland C++ is very old. Also Borland has a long history of straying from the standards. I am really surprised they are still around.


Agreed...better get a modern compiler which discourage you by disallowing you from using non standard functions."system("PAUSE");" can make the console window stay until you press any key.
This is bad programming practice and for the reasons why, you can see a really good article by my friend and moderator Mr. WaltP.

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 
This is bad programming practice and for the reasons why, you can see a really good article by my friend and moderator Mr. WaltP.




However, I think Lynqu2 will not use it ("system("PAUSE");" ) in any engineering projects.:)

Looben
Newbie Poster
12 posts since Dec 2006
Reputation Points: 10
Solved Threads: 1
 

Bad programming practice is bad programming practice, be it a simple "hello world" program or a complete software.

Maybe time and experience will teach you that, but lets hope its not the hard way for you....;)

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You