Hello, everyone,
I’m making a program in which, at the end, the user is asked to press ‘e’ to exit. My question is: Is there a function or just anything that will make the console to exit?
NOTE:
I’ve tried with exit(), system(“exit”) but it doesn’t work for me. Also I am NOT searching for something like ConsoleFree() or anything similar
Thank you in advance!
There are three possible things that I think you may be asking for (reasonably).
(1)
You want your program to terminate when the user presses 'e' (and then Enter!).
Use exit(0); anywhere in your code to do that.
(You should try to write programs that don't need to use it that way, though.)
(2)
You want your program to terminate when the user presses 'e' (and then Enter!) and also to destroy the console window.
Don't worry about it. It is the Wrong Thing to do. Your application should not be terminating the user's console.
If a console was spawned in order to run your application, it will automatically disappear when your application terminates.
(3)
You want your program to continue running when the user presses 'e' (and then Enter!), but to make the console go away.
Again, Don't Do That.
Not unless you explicitly made the console appear from your GUI program to begin with.
If this doesn't answer your question (even if you don't like the answer -- sorry), please give us more detail on what exactly you are trying to do for the user.