The program is compiling and I'm not getting any errors, but when I run the program, after I enter the first value, the program just terminates.
//carstruct.cpp -- Structure with information about cars
#include <iostream>
using namespace std;
struct car {char make[20]; int year;};
int main()
{
int cars;
cout << "How many cars do you want to catalog? ";
cin >> cars;
car *autos= new car[cars];
int i = 0;
while (i < cars)
{
cout << "Car # "<< i + 1 << endl;
cout << "Please enter the make: ";
cin.get(autos[i].make, 20);
cout << "\nPlease enter the year: ";
cin >> autos[i].year;
i++;
}
cout << "Here is your collection: ";
int j = 0;
while (j < cars)
{
cout << autos[j].year << " " << autos[j].make <<endl;
j++;
}
delete [] autos;
cin.get();
cin.get();
return 0;
}