RE: [Dev-C++] How to not close output win?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Rossi G. <Gio...@el...> - 2003-10-03 12:46:46
|
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...>
>
>
>
|