Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:关于getline函数的使用问题In Reply To:关于getline函数的使用问题 Posted by:zyxwg at 2005-05-28 11:28:41 template<class _E, class _Tr, class _A> inline basic_istream<_E, _Tr>& __cdecl getline(basic_istream<_E, _Tr>& _I, basic_string<_E, _Tr, _A>& _X, const _E _D) {typedef basic_istream<_E, _Tr> _Myis; ios_base::iostate _St = ios_base::goodbit; bool _Chg = false; _X.erase(); const _Myis::sentry _Ok(_I, true); if (_Ok) {_TRY_IO_BEGIN _Tr::int_type _C = _I.rdbuf()->sgetc(); for (; ; _C = _I.rdbuf()->snextc()) if (_Tr::eq_int_type(_Tr::eof(), _C)) {_St |= ios_base::eofbit; break; } else if (_Tr::eq((_E)_C, _D)) {_Chg = true; _I.rdbuf()->snextc(); /* 关键是这个东西用的不好. snextc:Advances the get pointer, then returns the next character. 本来应该是下面这个: stossc:Moves the get pointer forward one position, but does not return a character. */ break; } else if (_X.max_size() <= _X.size()) {_St |= ios_base::failbit; break; } else _X += _Tr::to_char_type(_C), _Chg = true; _CATCH_IO_(_I); } if (!_Chg) _St |= ios_base::failbit; _I.setstate(_St); return (_I); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator