c++ - program exits automatically -


i have created simple .exe file. when run it, closes automatically instead of saying "press key exit".

this program:

#include <iostream> #include <string> using namespace std; int main() {   string answer, yes = "yes";     cout << "is lucy top lass ? enter yes or no" << endl;   cin >> answer;   if (answer == yes)   {     cout << "correctomundo" << endl;   }   else   {     cout << " blasphemy ! " << endl;   }   return 0; } 

how make ask user press key before exiting?

also there way can change says else instead of "press key exit"?

try putting system("pause"); before return 0;


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -