Pausing execution of the program

Until now my methode of pausing the program was to write the following statements:

cout << "Press any key followed by the Enter key: ";
cin >> a; //the var a having been declared as an int

Now I have a code where I want to pause the program twice.

To make a long story short:

1. if the user inputs anything else than a digit the second pause is ignored

2. if the user inputs a digit: all is OK

3. if the cin variable is declared as a char, one can press any key and all is OK

Why? I'm sure I'm missing something simple!!

Just use this to std::cin.ignore(); to pause it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>

int main()
{
	std::cout << "Pausing program.\n";

	std::cin.ignore();

	std::cout << "Pausing program again.\n";

	std::cin.ignore();

	return 0;
}
Hi @philhar,
try using this
function "keep_window_open"

http://www.cplusplus.com/forum/beginner/125782/#msg681700
Thanks for the replies they wre informative!!
Topic archived. No new replies allowed.