RE: [Dev-C++] How to not close output win?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: P.D. v. Z. <pa...@my...> - 2003-10-03 13:42:56
|
How about the simplest solution of them all. Simply open a command prompt
yourself, go to your project directory, and execute your console program
from the command line. All those code workarounds are evil. Your "output
window" (console) closes because Dev-C++ simply launches the executable it
just compiled. Windows is responsible for the rest. In Windows, when a
console program has finished executing, its console is closed as well. This
is normal, standard behaviour, and has nothing to do with Dev-C++ (and
Dev-C++ isn't responsible for fixing this either). The solution to this
'problem' is to simply open a command prompt yourself (which you have to
close by yourself as well, will not be automatically closed), and execute
your program in there. Or has the Windows age alienated everyone from
anything having to do with command prompts?
Regards,
Paul
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of Rossi
Giovanni
Sent: Friday, October 03, 2003 2:45 PM
To: 'Reid Thompson'; Natalie Bryant; ber...@ce...
Cc: devc++
Subject: RE: [Dev-C++] How to not close output win?
You can use "atexit" :
atexit()
Prototype: int atexit(void (_USERENTRY * func)(void)); Header File: stdlib.h
ANSI: C and C++
Explanation: Use atexit to have a function called when the program exits.
The parameter it accepts is a function name, without the typical () of a
function call. It must return void and accept no values (hence the use of
void in the prototype of atexit). If atexit is called more than once, the
last function passed to it will be the first one executed. It can be used up
to 32 times.
Example:
#include <iostream.h>
#include <stdlib.h>
//Program calls atexit with FinalFunction //FinalFunction is executed before
program ends void FinalFunction(void) {
cout<<"Final function called - Press enter to exit";
cin.get(); // or system("pause")
}
int main()
{
atexit(FinalFunction);
return 0;
}
Best Regards
Gianni
> -----Original Message-----
> From: Reid Thompson [SMTP:Rei...@at...]
> Sent: Friday, October 03, 2003 1:45 PM
> To: Natalie Bryant; ber...@ce...
> Cc: devc++
> Subject: RE: [Dev-C++] How to not close output win?
>
> Create an exit function that has the system pause in it. Then,
> everywhere you wish to exit, call the exit function. Only have to
> have it in one place.
>
>
>
> reid
>
> -----Original Message-----
> From: Natalie Bryant [mailto:nap...@lo...]
> Sent: Friday, October 03, 2003 7:03 AM
> To: ber...@ce...
> Cc: devc++
> Subject: Re: [Dev-C++] How to not close output win?
>
>
> Thankyou Massimo,
>
> I'll bear that in mind for later when I need it.
>
> Kind regards
>
> Natalie
>
> ----- Original Message -----
> From: Massimo Bertozzi <mailto:kb...@ce...>
> To: Natalie Bryant <mailto:nap...@lo...>
> Cc: devc++ <mailto:dev...@li...>
> Sent: Friday, October 03, 2003 11:55 AM
> Subject: Re: [Dev-C++] How to not close output win?
>
> On Fri, Oct 03, 2003 at 11:39:33AM +0100, Natalie Bryant <
> nap...@lo... <mailto:nap...@lo...>>
> wrote:
>
> > Hi Neszt,
> >
> > Reid sent me this solution yesterday to the same problem.
> It instantly made everything work properly... Shown below.
>
> Yes, until you have a single exit in your program. When
you have
> more
> possibilities you have to replicate the system("pause")
everywhere.
>
> M.
> --
> Massimo Bertozzi
> Dipartimento di Ingegneria dell'Informazione Voice:
> +39 0521 90 5735
> Parco Area delle Scienze, 181A, Parma, ITALY Fax:
> +39 0521 90 5723
> WWW: <http://www.ce.unipr.it/people/bertozzi> E-mail:
> ber...@CE... <mailto:ber...@CE...>
>
>
>
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|