标题:cin getline输入问题
取消只看楼主
kspliusa
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:98
专家分:178
注 册:2009-9-27
结帖率:80%
已结贴  问题点数:20 回复次数:2 
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麻烦哪位高手帮帮我!!先谢谢了!
搜索更多相关主题的帖子: 输入 getline cin 
2009-09-27 16:12
kspliusa
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:98
专家分:178
注 册:2009-9-27
得分:0 
回复 2楼 pywepe
谢谢啊!!可是为什么我上面的程序输入的时候出了问题啊,帮我看看吧!!
2009-09-27 18:16
kspliusa
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:98
专家分:178
注 册:2009-9-27
得分:0 
回复 4楼 gz81
呵呵,好的,不过还是非常感谢指教!!
2009-09-28 15:35



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-287083-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.873637 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved