Hi,
I have made a small program and have added system("pause");
at the end of the program file.
I wanted to know that is it necessary that we should add this "system("pause"); at the end of a program?
When do we actually have to use this?
Thanks
Hi,
I have made a small program and have added system("pause");
at the end of the program file.
I wanted to know that is it necessary that we should add this "system("pause"); at the end of a program?
When do we actually have to use this?
Thanks
It isn't.Originally Posted by student111
Never, except in the special case when you actually have to invoke a "pause" command for some exceedingly special reason, in which case you won't need to ask because you already know. Refer to this article on keeping the console window open.Originally Posted by student111
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I prefer using:
It's an extra line of code, but it avoids using system commands.Code:std::cin.ignore(); //ignores any information currently waiting to be gathered such as enters etc std::cin.get(); //requests user input. This will pause your program