getline sting tmp;while(getline(cin,tmp))cout<<tmp<<endl;为什么连续两次回车后while循环不退出呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 应该没什么问题啊,上面sting tmp应该是打错了吧 sting tmp改为string tmp;不能退出循环呀 template<class CharType, class Traits, class Allocator> basic_istream<CharType, Traits>& getline( basic_istream<CharType, Traits>& _Istr, basic_string<CharType, Traits, Allocator>& _Str);The first function returns getline( _Istr, _Str, _Istr.widen( '\n' ) ). 长度为0的string也是有效的。加判断: while(getline(cin,tmp)) { if(0 == tmp.length()) { break; } cout<<tmp<<endl; } 只能这样吗? 难道getline就是这么设计的? getline 是这样要求退出的吗? 是的Ctrl+Z就相当于文件结束符eof windows下crtl+z linux下ctrl+d 详细的你可以看一下下面的文章http://www.javaeye.com/wiki/topic/686817 Post返回400错误,可能是发送的数据有问题 谁来帮帮我 求DSOFRAMER控件全屏实现代码 自定义窗体点击最小化按钮时,Debug下中断,Release下正常 新注册的小菜鸟只能在这里发帖求助了 CListCtrl 问题 我也离职了~不想继续呆在那~散分-_-# 问一个CFileDialog的问题 ActiveX控件RemoteData Control,DBGrid Control用法,怎样在程序里面设置控件属性,绑定数据列? 怎样用ado获取一个表中第i个字段的名字? vc 大虾, 这边请! 为什么会报错呢!!!!!! 关于句柄的问题
string tmp;
不能退出循环呀
template<class CharType, class Traits, class Allocator>
basic_istream<CharType, Traits>& getline(
basic_istream<CharType, Traits>& _Istr,
basic_string<CharType, Traits, Allocator>& _Str
);The first function returns getline( _Istr, _Str, _Istr.widen( '\n' ) ).
加判断:
while(getline(cin,tmp))
{
if(0 == tmp.length())
{
break;
}
cout<<tmp<<endl;
}
只能这样吗? 难道getline就是这么设计的?
getline 是这样要求退出的吗?
是的
Ctrl+Z就相当于文件结束符eof
http://www.javaeye.com/wiki/topic/686817