Close console window in C
I need to create the Old Lady's game. I want to know how to close the black window that appears without having to click any key, for example: When running the program appears:
1 to play
0 to exit
If the user enters 0 i want the program to close completely without having to click Enter.
1 answers
According to an OS question :
The console (or shell) in which the program is running is completely independent of your program, it is just a user interface (I/O). Trying to close the console is not a good idea - instead you should boot your program without tying it. (this is easy in the Unix environment, but harder on Windows)
In Unix you should look over the command kill(2)
.
In Windows you need to run a command killing the process by its name: system("taskkill /IM cb_console_runner.exe")
.