void input() {
ofstream In("AutoBase.txt", ios::binary);
char k = '+';
AutoBase a;
string Read;
while (k == '+') {
cout << "Enter name of car: "; getline(cin, a.Name);
cout << "Enter Release Date with a point '10.10.2010': "; getline(cin, Read);
a = Divide(a, Read, 0);
cout << "Enter Sale Release Date with a point '10.10.2010': "; getline(cin, Read);
a = Divide(a, Read, 1);
cout << "Enter '+' in case you want to contnue: "; cin >> k;
In.write((char*)&a, sizeof(AutoBase));
cin.ignore();
}
In.close();
}
AutoBase Divide(AutoBase a, string Read, bool b) {
int pos1 = Read.find('.');
int pos2 = Read.rfind('.');
if (!b) {
a.Release.day = stoi(Read.substr(0, pos1));
a.Release.mounth = stoi(Read.substr(pos1 + 1, pos2));
a.Release.year = stoi(Read.substr(pos2 + 1));
}
else {
a.SaleRelease.day = stoi(Read.substr(0, pos1));
a.SaleRelease.mounth = stoi(Read.substr(pos1 + 1, pos2));
a.SaleRelease.year = stoi(Read.substr(pos2 + 1));
}
return a;
}