#include
#include
using namespace std;
int main()
{
int x, i;
struct car
{
string m;
int y;
};
cout << "how many cars do you have?" << endl;
cin >> x;
car* swp = new car[x];
for (i = 0; i < x; ++i)
{
cout << "Car #" << i+1 << ":" << endl;
cout << "please enter the make: ";
getline(cin, swp[i].m);
cin.get();
cout << endl << "please enter the year: ";
cin >> swp[i].y;
}
cout << "here is your collection:" << endl;
for (i = 0; i < x; ++i)
{
cout << swp[i].y << " " << swp[i].m << endl;
}
delete[] swp;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
int x, i;
struct car
{
string m;
int y;
};
cout << "how many cars do you have?" << endl;
cin >> x;
car* swp = new car[x];
for (i = 0; i < x; ++i)
{
getchar();
cout << "Car #" << i+1 << ":" << endl;
cout << "please enter the make: ";
getline(cin, swp[i].m);
cout << endl << "please enter the year: ";
cin >> swp[i].y;
}
cout << "here is your collection:" << endl;
for (i = 0; i < x; ++i)
{
cout << swp[i].y << " " << swp[i].m << endl;
}
delete[] swp;
return 0;
}