#include <iostream>
#include <string>
using namespace std;
struct car
{
string make;
int year;
};
int main()
{
int n;
cin >> n;
car * pt = new car[n];
for (int i=0; i<n; i++)
{
getline(cin, pt[i].make);
cin >> pt[i].year;
}
for (int i=0; i<n; i++)
cout << pt[i].year << ' ' << pt[i].make << endl;
return 0;
}
When I keyed in the input, I can only key in one number and one string. The program then displays some zeros. It prevents me from keying in more input. Can anybody explain me to what happened and how to solve this problem in C++? Thank you!