I'm learning how to write data to binary file and how to read it.
Here's a program. when I run it and choose option to display all departments it displays two departmnts at once and then waits for the user input to display next department.
#include<iostream>
#include<string>
#include<cstring>
#include<fstream>
using namespace std;
The reason is that an the operator >> (e.g. cin >> choice;) leaves a whitespace/end of line in the stream. cin.get(); will retrieve that remaining whitespace and does not wait for user input. You can avoid this when you put ws after the operator >>: