Is system(“pause”) correct way to pause program?
when we are beginning to start learning C or C++ most common they face is the fast execution they can’t see the output appeared on the console . the most common way to pause program is system(“pause”) ;
system pause invokes the operating system for our C++ programs.
if you use this command you get output like
hello World
press any key to continue …
if you want to erase this “press any key to continue” you can use
system(“pause>0”);
but this is platform dependent solution this won’t work in Linux , Mac or Unix the solution that is not platform dependent is
cin.get() ;
you may also use cmd in windows or terminals to compile the programs because they give control to the console again .
g++ <program-name.cpp>
g++ hello.cpp
[C:\Users\HP]
PS:2 >g++ hello.cpp
hello world
[C:\Users\HP]
PS:2 >
Tell me if you know more commands to pause the screen in C++ thanks if you‘ve fully read the article
thanks and Happy programming