连续的cin的问题 [英] Problem with consecutive cin's

查看:134
本文介绍了连续的cin的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include<iostream>

int main()
{
    int x, y;
    cin >> x ;  
    cin >> y ;   // This gets ignored
}

-D在第一次cin第二cin被忽略。如何在第一次cin后按ctr-D后使第二个cin工作。

Hi in above prog after pressing Ctrl-D during first cin second cin gets ignored. how i can make second cin work after pressing ctr-D during first cin. cin.ignore() and cin.clear() doesn;t seem to work.

我的问题是,如果在第一次cin时按ctrl-D基本上我离开eof char在i / p流中,这是不会被读取和它在那里reamins。现在不能从流中删除此字符,以便它可以再次输入。如果不是什么是背后的确切原因。

My question is that if im pressing ctrl-D during first cin bascially i am leaving eof char in i/p stream which is not going to be read and it reamins there. now can't i remove this character from the stream so that it's ready again for input. if not what's the exact reason behind it.

推荐答案

Ctrl-D 文件。在这种情况下,它表示 stdin 流的结束,这意味着什么也不能再读。

Ctrl-D is for end-of-file. In this case, it indicates the end of the stdinstream, which means nothing is to be read again.

这篇关于连续的cin的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆