Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include "employees.h"
- using std::cin, std::cout;
- int main() {
- string com, file;
- EmployeesArray arr;
- while (true) {
- cin >> com;
- if (com == "add") {
- cin >> arr;
- }
- if (com == "list") {
- cout << arr;
- }
- if (com == "save") {
- cin >> file;
- std::ofstream Out;
- Out.open(file, std::ios::out | std::ios::binary);
- Out << arr;
- Out.close();
- }
- if (com == "load") {
- cin >> file;
- std::ifstream In;
- In.open(file, std::ios::in | std::ios::binary);
- if ((In.rdstate() & std::ifstream::failbit) != 0)
- std::cerr << "Error opening " << file << '\n';
- In >> arr;
- In.close();
- }
- if (com == "exit") {
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement