What is the difference between using system("pause") and cin.get(pause)?
Oliver told me never use system("pause").

#include<string>
#include<iostream>

int main(){
 using namespace std;

  string str = "My name is shridhar";
  cout<<"What is your name"<<str;

  char pause = 0;
  cout << "Press enter to continue...";
  cin.get(pause);
}

One (system("pause")) involves asking the operating to run a system command and spawn a new process and the other simply waits for input to your program. They are about as different as night and day. As to which to use, cin.get() is usually preferred. If you do a quick Daniweb search on system("pause"), the reasons have been written up pretty well.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.