单个字符 (1) | int_type get();basic_istream& get (char_type& c); |
---|---|
c-string (2) | basic_istream& get (char_type* s, streamsize n);basic_istream& get (char_type* s, streamsize n, char_type delim); |
stream buffer (3) | basic_istream& get (basic_streambuf<char_type,traits_type>& sb);basic_istream& get (basic_streambuf<char_type,traits_type>& sb, char_type delim); |
(n-1)
characters have been extracted or the delimiting character is encountered: the delimiting character being either the newline character (widen('\n')
) or delim (if this argument is specified).char_type()
) is automatically appended to the written sequence if n is greater than zero, even if an empty string is extracted.true
). Then (if good), it extracts characters from its associated stream buffer object as if calling its member functions sbumpc or sgetc, and finally destroys the sentry object before returning.2
, the function does not extract any characters and sets failbit.traits_type::eof()
) if no characters are available in the stream (note that in this case, the failbit flag is also set).*this
. Note that this return value can be checked for the state of the stream (see casting a stream to bool for more info).flag | error |
---|---|
eofbit | 函数停止提取字符,因为输入序列没有更多可用字符(已到达 文件末尾)。 |
failbit | Either no characters were written or an empty c-string was stored in s. |
badbit | 流错误(例如,当此函数捕获由内部操作抛出的异常时)。 When set, the integrity of the stream may have been affected. |
|
|