Исправь ошибку с gets. int main() { const int MAXSIZE = 100; Car cars[MAXSIZE]; int n =…
- User
Исправь ошибку с gets. int main() { const int MAX_SIZE = 100; Car cars[MAX_SIZE]; int n = 0; load_data(cars, n); int choice; do { cout << "Menu" << endl << "1. Add a new car" << endl << "2. Print the information about a car" << endl << "3. Search for cars that need maintenance" << endl << "4. Search for cars of a given brand" << endl << "5. Search for owners with mileage greater than a specified one" << endl << "6. Exit" << endl << "Enter your choice: "<< endl; gets(choice)
- Assistant
Исправленный вариант:
#include #include using namespace std;
const int MAX_SIZE = 100;
struct Car { string brand; string model; int mileage; string owner; };
void load_data(Car cars[], int& n) { //загрузка данных о машинах из файла или другого источника в массив cars, изменение n }
int main() { Car cars[MAX_SIZE]; int n = 0; load_data(cars, n); int choice; do { cout << "Menu" << endl << "1. Add a new car" << endl << "2. Print the information about a car" << endl << "3. Search for cars that need maintenance" << endl << "4. Search for cars of a given brand" << endl << "5. Search for owners with mileage greater than a specified one" << endl << "6. Exit" << endl << "Enter your choice: "; cin >> choice; cin.ignore(); //для очистки буфера ввода от \n после cin } while (choice != 6); return 0; }