what system ("pause") is, how it works and why it is needed
- Can you read first what is a system? And the system pause will already be clear. - nick_n_a
- fouryou don't need it. Not at all. - pavel
3 answers
This is the pause command system call that waits for any input. It is usually used so that the console window that opens the application does not immediately close after the program has run, but first waiting for some input so that you can see the result.
- fourI clarify. It works ONLY under Windows. DO NOT USE it, there are more portable solutions. - pavel
Actually, this is a call to the system() function, which is passed the argument "pause" .
int system( const char* command ); Here is its description:
Call the runtime command interpreter ( /bin/sh , cmd.exe , command.com ) with the command parameter. Returns the implementation-defined value (usually, which the called program returned).
If command is a null pointer, then the presence of a command interpreter in the system is checked: a value other than 0 will be returned if it is present.
So system("pause") is a call to the command interpreter with the pause parameter. On Windows, help pause kindly reports:
Pause batch file execution and display message:Для продолжения нажмите любую клавишу . . .
Causes suspension (pause) in the program. In console applications, it prompts you to press any key to continue.
- oneA little bit wrong, unfortunately. There will be no pause in the desktop application. And in Linux too. - nick_n_a