Visual Studio different output from Primer book exercise

Hi, I'm following the C++ Primer, for the section 1.4.4, when I type the code into Visual Studio it doesn't show the last entered input how many times occurs. But when I use an online compiler it gives the expected output.
Input : 3 5 6
Visual Studio gives :
3occurs 1times
5occurs 1times
Online Compiler gives :
3occurs 1times
5occurs 1times
6occurs 1times

What could be the problem here please?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  #include <iostream>

int main() {
	int previous = 0;
	int current = 0;
	if (std::cin >> previous) {
		int cnt = 1;
		while (std::cin >> current) {
			if (current == previous) {
				++cnt;
			}
			else {
				std::cout << previous << "occurs " << cnt << "times " << std::endl;
				previous = current;
				cnt = 1;
			}

		}
		std::cout << previous << "occurs " << cnt << "times " << std::endl;
	}
	system("pause");
	return 0;
}
my guess is that you don't know how to terminate the input. (how to send EOF)
Topic archived. No new replies allowed.