by passing exit c++

Feb 11, 2012 at 10:03am
does anyone know how to bypass exit?
as in it will not ask for "press any key to continue". program will directly exit.
Feb 11, 2012 at 10:11am
It is probably your IDE that is prompting for you to press any key, C++ programs don't automatically ask you to press any key when they finish executing.
Feb 11, 2012 at 10:15am
What IDE are you using? Try using different IDE and see what happens.

As yasar11732 said C++ programs automatically exit after they have finished executing.

Did you maybe write system("PAUSE"); or something similar to it in the end of your code? If yes, remove it.

S.
Feb 11, 2012 at 10:25am
Execute from a terminal.

You can register functions with atexit()
Feb 11, 2012 at 1:01pm
escape()
{
cout<<"\n\n\n\n Thank You For Using Master Aryhan's Work!";
timer();
system ("cls");
atexit (0);
return 0;
}

here is my code.. when 'e' is press it will direct you to function escape()
what i like is when the atexit() or exit () runs.. it will no longer display "Press any key to continue" to close the console.
Feb 11, 2012 at 1:02pm
by the way.. what is IDE?
Feb 11, 2012 at 1:12pm
IDE stands for "Integrated Development Environment." For example, Eclipse, Netbeans, Visual C++ etc. are all IDE's. If you don't write your program using a regular text editing program and compile it from a terminal, the program you are using to write and compile your programs is an IDE.
Feb 11, 2012 at 1:24pm
i think im using visual c++ 6.0
Feb 11, 2012 at 2:03pm
I'm pretty sure there is an option in VC++6.0 to turn off the "Press any key..." behavior.

It shouldn't be an issue, because the only time you will see that is when you run your program from inside the IDE/editor.

The atexit() function registers a close-down function. You don't need it.
You also don't need to be clearing the screen before your program terminates.

1
2
3
4
5
6
void escape()
{
  cout<<"\n\n\n\n Thank You For Using Master Aryhan's Work!" << flush;
  timer();
  exit(0);  /* <-- this terminates your program */
}


Hope this helps.
Last edited on Feb 11, 2012 at 2:04pm
Feb 11, 2012 at 2:21pm
ahh i see,, when you run the .exe of this program,, the "press any key..." will not appear? thanks!
Feb 11, 2012 at 7:31pm
That is correct. I usually test my programs from the console anyway... but you can also test them by using Windows Explorer to find your program's EXE and double-clicking it.
Topic archived. No new replies allowed.