cin getline输入问题
大家好,我想问一个问题。就是#include <iostream>
#include <cstring>
using namespace std;
struct datas{
string name;
double diameter;
double weight;
};
int main()
{
datas *pn = new datas;
cout<<"Enter the diameter of the pizza:\n";
cin>>pn->diameter;
cout <<"Enter the name:\n";
getline(cin,pn->name);
cout <<"Enter the weight of the pizza:\n";
cin>>pn->weight;
cout <<pn->name<<"\n"<<pn->diameter<<"\n"<<pn->weight<<endl;
delete pn;
return 0;
}
这个程序为什么不能在输入diameter后不等待输入name而直接就出现Enter the name:Enter the weight of the pizza麻烦哪位高手帮帮我!!先谢谢了!