| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 632 人关注过本帖
标题:C++ 循环输入不能通过的问题
取消只看楼主 加入收藏
z562586756
Rank: 1
等 级:新手上路
帖 子:18
专家分:1
注 册:2011-4-30
结帖率:16.67%
收藏
 问题点数:0 回复次数:0 
C++ 循环输入不能通过的问题
初学c++,编写了这样一个程序,目的是循环输入3种不同类型的数据,遇到结尾退出。。

#include<iostream.h>
#include<stdlib.h>
#include<stdio.h>
void main ()
{
    float *pf=new float;
    long *pl=new long;
    char *pc=new char;
    cout<<"please input float and input EOF to quit"<<endl;
    while (cin>>*pf)
    cout<<*pf<<endl;
    cout<<"please input long and input EOF to quit"<<endl;
    while (cin>>*pl)
    cout<<*pl<<endl;
    cout<<"please input char and input EOF to quit"<<endl;
    while (cin>>*pc)
    cout<<*pc<<endl;
}

但是运行后只能输入float数据。输入结尾后就直接结束了,为什么啊?
是不是没有清空输入流? 还是要怎么做?
搜索更多相关主题的帖子: include please 
2011-09-10 09:31
快速回复:C++ 循环输入不能通过的问题
数据加载中...
 
   



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

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