| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1132 人关注过本帖
标题:关于cin.clear()
取消只看楼主 加入收藏
最近不在
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:5
帖 子:204
专家分:842
注 册:2010-2-28
结帖率:95%
收藏
已结贴  问题点数:10 回复次数:0 
关于cin.clear()
程序代码:
#include<iostream>
using namespace std;
const int max=5;
int main()
{
    int golf[max];
    cout<<"please input your golf scores.\n";
    cout<<"you must enter "<<max<<" rounds.\n";
    int i;
    for(i=0;i<max;i++)
    {
        cout<<"round #"<<i+1<<":";
        while(!(cin>>golf[i]))
        {
            cin.clear();//为什么我删除这行后,输入非数字后,无法再输入
            while(cin.get()!='\n')
            continue;
            cout<<"please input a number:\n";
            cout<<"round #"<<i+1<<":";
        }
    }
    return 0;
}
搜索更多相关主题的帖子: clear cin 
2010-03-08 17:30
快速回复:关于cin.clear()
数据加载中...
 
   



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

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