Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <string.h>
- #include <cstdlib>
- #include <vector>
- #include <algorithm>
- #include <Windows.h>
- using namespace std;
- inline void eatline() { while (cin.get() != '\n') continue; }
- struct Information
- {
- char Name[20];
- char Date[10];
- char Problem[100];
- char Status[14];
- };
- int main()
- {
- /*SetConsoleCP(1251);
- SetConsoleOutputCP(1251);*/
- cout << left;
- int n;
- cout << "Enter n: ";
- cin >> n;
- vector<Information> list(n);
- //vector<Information> list2(n);
- cin.ignore(100, '\n');
- cin.clear();
- unsigned int i = 0;
- while (i < list.size())
- {
- cout << "Fill list " << i + 1 << ":" << endl << "Name: ";
- cin.get(list.at(i).Name, 20);
- eatline();
- cout << "Date: ";
- cin.get(list.at(i).Date, 10);
- eatline();
- cout << "Problem: ";
- cin.get(list.at(i).Problem, 100);
- eatline();
- cout << "Status: ";
- cin.get(list.at(i).Status, 20);
- eatline();
- i++;
- }
- ofstream ss("text.dat", ios::out | ios::app | ios::binary);
- ss.write((char*)(&list[0]), sizeof(list[0]) * list.size());
- ss.close();
- //
- ifstream num("text.dat", ios::binary);
- num.seekg(0, ios::end);
- int count = num.tellg() / sizeof(Information);
- num.seekg(0, ios::beg);
- num.close();
- cout << "Count: " << count;
- //
- vector<Information> list2(count);
- //
- ifstream iss;
- iss.open("text.dat", ios::in | ios::binary);
- iss.read((char*)(&list2[0]), sizeof(list2[0]) * list2.size());
- cout << "****************************************************************" << endl;
- iss.close();
- for (unsigned int j = 0; j < list2.size(); j++)
- {
- cout << "list " << j + 1 << ":" << endl << "Name: " << endl << setw(5) << list2.at(j).Name << endl << setw(9) << "Date: " << endl << list2.at(j).Date << endl << "Problem: " << endl << setw(1) << list2.at(j).Problem << endl << "Status: " << endl << setw(1) << list2.at(j).Status << endl;
- }
- char st[10];
- *st = 0;
- strcat(st, "processed");
- for (unsigned int k = 0; k < list2.size(); k++)
- {
- if (strstr(list2.at(k).Status, st) != NULL)
- {
- list2.erase(list2.begin() + k);
- }
- }
- cout << "Done!!!!!!!" << endl;
- for (unsigned int j = 0; j < list2.size(); j++)
- {
- cout << "list " << j + 1 << ":" << endl << "Name: " << endl << setw(5) << list2.at(j).Name << endl << setw(9) << "Date: " << endl << list2.at(j).Date << endl << "Problem: " << endl << setw(1) << list2.at(j).Problem << endl << "Status: " << endl << setw(1) << list2.at(j).Status << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement