сделай чтобы не использовалась bool
bool exit = false;
while (!exit) {
int choice;
cout << "1. Add a new car" << endl;
cout << "2. Print car information" << endl;
cout << "3. Find cars with more than 18 months since last service" << endl;
cout << "4. Find cars of a specified brand" << endl;
cout << "5. Find owners with mileage greater than specified (sorted by alphabet)" << endl;
cout << "6. Exit" << endl;
cout << "Choose an action: ";
cin >> choice;
cin.ignore();

if (choice == 1) {
cout << "Enter the number of new cars: ";
int k;
cin >> k;
cin.ignore();
car *new_cars = new car[k];
add_car(new_cars, k);
car *temp_cars = new car[n+k];
memcpy(temp_cars, cars, n * sizeof(car));
memcpy(temp_cars + n, new_cars, k * sizeof(car));
n += k;
delete[] cars;
delete[] new_cars;
cars = temp_cars;
}
else if (choice == 2) {
print_cars(cars, n);
}
else if (choice == 3) {
search_cars(cars, n, current_date);
}
else if (choice == 4) {
char *brand = new char[20];
cout << "Enter the brand to search for: ";
gets(brand);
find_brand(cars, n, brand);
delete[] brand;
}
else if (choice == 5) {
int mileage_limit;
cout << "Enter the mileage limit: ";
cin >> mileage_limit;
cin.ignore();
sort_print_high_mileage(cars, n, mileage_limit);
}
else {
exit = true;
}
}