C/C++ on Linux/Unix

Moderators: Lundin
Number of threads: 336
Number of posts: 663

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Program executes, but close split second later. Posted by Stucky on 5 Jul 2007 at 8:34 PM
It's doing exactly what the title says. I use Nano in Cygwin to make the code. Then I use GCC to compile it. It comes out with the a.exe file like always. But when I try to run the program using windows explorer the window opens and then closes a split second later, I can barely even see what's printed on the screen. I'm 100% sure the program doesn't have any errors, because I've double checked it, triple checked, and I copied it straight from the book "C Programming for Absolute Beginners". It might be able to run if I start it up with the command prompt in Cygwin. But I've tried that with the "run" command and nothing happens. Please help me.
Report
Re: Program executes, but close split second later. Posted by BitByBit_Thor on 6 Jul 2007 at 2:48 AM
: It's doing exactly what the title says. I use Nano in Cygwin to make
: the code. Then I use GCC to compile it. It comes out with the a.exe
: file like always. But when I try to run the program using windows
: explorer the window opens and then closes a split second later, I
: can barely even see what's printed on the screen. I'm 100% sure the
: program doesn't have any errors, because I've double checked it,
: triple checked, and I copied it straight from the book "C
: Programming for Absolute Beginners". It might be able to run if I
: start it up with the command prompt in Cygwin. But I've tried that
: with the "run" command and nothing happens. Please help me.
:

Try opening a DOS command window and running it... or put a 'pause' at the end of the code (like waiting for input).

Best Regards,
Richard

The way I see it... Well, it's all pretty blurry
Report
Re: Program executes, but close split second later. Posted by unixfreak on 9 Jul 2007 at 1:59 PM
uat the very end before exit or return;
use
getchar();
the command line will wait for you to enter any char and this goes to stack, so you dont have to worry about it
Report
Re: Program executes, but close split second later. Posted by da_comp_guy on 25 Jul 2007 at 3:42 AM
: uat the very end before exit or return;
: use
: getchar();
: the command line will wait for you to enter any char and this goes
: to stack, so you dont have to worry about it
:
yes .. in fact if u want it 2 b a bit more user friendly ... use
 system("PAUSE"); [\code]
this function is in the <stdlib.h> or <cstdlib> in some platforms.
or u can go for the old way of using getch() at the end of the source ...
cya !

"The GEEK Shall Inherit The Earth"  
Report
Re: Program executes, but close split second later. Posted by Stucky on 4 Aug 2007 at 2:50 PM
Thanks for all your help, but I need something else. I tried everything except opening it in DOS. Could someone please direct me to a good DOS emulator for Windows XP service pack 2.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.