帮小弟我看下 为啥结果会空一行

帮我看下 为啥结果会空一行


[code=C/C++][/code]
# include<iostream>
# include<string>
using namespace std;
struct car
{
string name;
int year;
};
int main()
{
cout<<"How many cars do you want to inquire:";
int i;
cin>>i;
car* ps= new car[i];
for(int j=0;j<i;j++)
{
cout<<"Car #"<<j+1<<endl;
  cout<<"please enter the make:";
  cin.get();
getline(cin,ps[j].name); 
//cin.get();
  //getline(cin,*(ps+j).name);
cout<<"please enter the year made:";
cin>>ps[j].year;  
};

delete []ps;
return 0;
}


------解决方案--------------------
单步调试和设断点调试是程序员必须掌握的技能之一。

------解决方案--------------------
因为你使用的cin.get()和getline()函数都是以回车键为结束符的,所以要按两次回车键才能继续进行下一步年份的读入
------解决方案--------------------
endl会换行,get()也会换行
------解决方案--------------------
多了一个cin.get()