by passing exit c++

does anyone know how to bypass exit?
as in it will not ask for "press any key to continue". program will directly exit.
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.
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.
Execute from a terminal.

You can register functions with atexit()
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.
by the way.. what is IDE?
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.
i think im using visual c++ 6.0
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
ahh i see,, when you run the .exe of this program,, the "press any key..." will not appear? thanks!
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.