Skip to content

Instantly share code, notes, and snippets.

@2hanX
Created June 18, 2020 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2hanX/b13dbbf75a89bacedffd76e6253b002e to your computer and use it in GitHub Desktop.
Save 2hanX/b13dbbf75a89bacedffd76e6253b002e to your computer and use it in GitHub Desktop.
#include<iostream>
#include<string>
using namespace std;
struct Car
{
string build;
int year;
};
int main()
{
int cars;
cout << "How many cars do you wish to catalog? ";
cin >> cars;
cin.get();
Car *car = new Car[cars];
for (int i = 0; i < cars; i++)
{
cout << "Car #" << i+1 << ":\n";
cout << "Please enter the make: ";
getline(cin, car[i].build);
cout << "Please enter the year made: ";
cin >> car[i].year;
cin.get();
}
cout << "Here is your Hornet" << endl;
for (int j = 0; j < cars; j++)
{
cout << car[j].year << " " << car[j].build << endl;
}
delete[] car;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment