LasTSurvivoR
- 16
- 0
I wrote my code and try to setup the program , desperately the program closes it so quickly return 0 or getch() commands doesn't work how can I prevent it with a code ?
The discussion focuses on preventing a console application from closing immediately after execution in MS-DOS environments. Users recommend several methods, including using getchar(), getch(), and system("PAUSE") to keep the console window open. It is noted that executing the program from the command line instead of double-clicking it can also resolve the issue. Additionally, Visual C++ is mentioned as a compiler that automatically manages this behavior.
getchar() and getch()getchar() and getch() in C/C++system() function and its implications in C/C++Programmers developing console applications, students learning C/C++, and anyone troubleshooting console behavior in Windows environments.
printf("\npress q to quit\n");
do
{
key = getchar();
} while (key != 'q');
printf("\npress q to quit\n");
do
{
key = getch();
} while (key != 'q');