It is necessary to remove all items whose release year is less than the specified one.
Here is the code: it creates the file and we write the structure there, but then I need to enter the year and the program should delete all the lines that have a year less than the specified one. How to do it?
#include <iostream> #include <fstream> #include <string> using namespace std; struct avto { string mark; string cost; string year; string cvet; }; int main() { int MAX; cout <<"vvedite col-vo avto\n"; cin>>MAX; avto b[MAX]; for (int i=0;i<MAX;++i) { cout << "Enter mark :" << endl; cin >> b[i].mark; cout << "Enter cost :" << endl; cin >> b[i].cost; cout << "Enter year :" << endl; cin >> b[i].year; cout << "Enter cvet :" << endl; cin >> b[i].cvet; } ofstream outfile; outfile.open("Out.txt"); for (int i=0;i<MAX;++i) { outfile << b[i].mark << " " << b[i].cost << " " << b[i].year << " " << b[i].cvet << endl; } system("pause"); return 0; }