Here I have a code:
cout << "Press Enter To Exit...";
cin.ignore();
this program will execute and will wait till you press enter and then it will exit.
now see this code:
int m;
cin >> m;
cout << "Press Enter To Exit...";
cin.ignore();
this time after entering a number for saving in “m” the program will exit without waiting for cin.ignore command which waits for pressing enter.
I mean if you use cin command before cin.ignore, the cin.ignore command will skip. why? and what should I do for fixing it?
Use this.