结束了 [英] End of cin

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

问题描述

我有一个简单的程序:


int main()

{

字符串缓冲区;

while(cin>>缓冲区)

cout<<缓冲区<< " ;


返回0;

}


当我从控制台输入字符串时,如何停止输入?我点击CTR + D但

它不会工作?


提前致谢。

I have a simple program:

int main()
{
string buffer;
while( cin>> buffer)
cout << buffer << " ";

return 0;
}

When I input string from console, how can I stop input? I click "CTR+D" but
it won''t work?

Thanks in advance.

推荐答案

char strMyString [100];


我总是做一个cin.get(strMyString,''\ n'');


然后它会得到字符串,直到你按下Enter键... :)(我认为..

..嘿)

" newbiecpp" <是ne ******* @ yahoo.com>在消息中写道

news:zCzPc.245
char strMyString[100];

I always do a cin.get(strMyString, ''\n'');

Then it will get the string until you hit the Enter key... : ) (I think..
..heh)
"newbiecpp" <ne*******@yahoo.com> wrote in message
news:zCzPc.245


qM.35@trndny01 ...
qM.35@trndny01...
我有一个简单的程序:

int main()
{
字符串缓冲区;
while(cin>>缓冲区)
cout<<缓冲区<< " " ;;

返回0;


当我从控制台输入字符串时,如何停止输入?我点击CTR + D
但它不起作用?

提前致谢。
I have a simple program:

int main()
{
string buffer;
while( cin>> buffer)
cout << buffer << " ";

return 0;
}

When I input string from console, how can I stop input? I click "CTR+D" but it won''t work?

Thanks in advance.



在星期一, 2004年8月2日15:54:23 -0700,newbiecpp写道:
On Mon, 02 Aug 2004 15:54:23 -0700, newbiecpp wrote:
当我从控制台输入字符串时,如何停止输入?


这取决于应用程序启动的环境。

我点击CTR + D但是它不起作用?
When I input string from console, how can I stop input?
That depends on the environment in which the application is started.
I click "CTR+D" but it won''t work?




这适用于Linux(以及我认为的其他unix)。对于Windows,请尝试

Ctrl-Z。


Ali



That works under Linux (and other unixes I think). For Windows, try
Ctrl-Z.

Ali


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

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