#include "stdafx.h"
#include
#include
using namespace std;
int main()
{
struct car {
string name;
int year;
};
int i = 0, j = 0;
cout << "how many cars do you want to catalog ?" << endl;
cin >> i;
car *cars = new car[i];
cin.get();
for (j = 0; j <= i; j++) {
cout << "please enter the make: ";
getline(cin, cars[i].name);
cout << "please enter the year: ";
cin >> cars[i].year;
cin.get();
}
cout << "here is your collection: " << endl;
for (j = 0; j <= i; j++) {
cout << "nmae: " << cars[i].name << endl;
cout << "year: " << cars[i].year << endl;
cout << endl;
}
delete []cars;
return 0;
}
运行这段代码后显示文件已停止工作
请问如何解决