std::basic_istream::readsome
来自cppreference.com
< cpp | io | basic istream
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
std::streamsize readsome( char_type* s, std::streamsize count ); |
||
从输入流中提取立即可用的字符.
原文:
Extracts immediately available characters from the input stream.
表现为
UnformattedInputFunction
。在构造和检查岗哨对象的, 原文:
Behaves as
UnformattedInputFunction
. After constructing and checking the sentry object, 如果rdbuf()->in_avail() == -1,要求setstate(eofbit)和提取任何字符.
原文:
If rdbuf()->in_avail() == -1, calls setstate(eofbit) and extracts no characters.
如果rdbuf()->in_avail() == 0,提取任何字符.
原文:
If rdbuf()->in_avail() == 0, extracts no characters.
如果rdbuf()->in_avail() > 0,提取std::min(rdbuf()->in_avail(), count))字符,并将它们存储到连续的的characater数组,该数组的第一个元素的位置所指向的
s
.原文:
If rdbuf()->in_avail() > 0, extracts std::min(rdbuf()->in_avail(), count)) characters and stores them into successive locations of the characater array whose first element is pointed to by
s
.目录 |
[编辑] 注释
这个函数的行为是非常特定于实现的。例如,当用于std::ifstream,一些编译器填补用数据底层filebuf只要打开该文件(和readsome的()这样的编译器中读取数据,有可能,但不一定是,整个文件),而其他的编译器只能读取当实际的输入操作从文件的要求(和readsome()发出文件打开后,从来没有提取任何字符)。同样,调用std::cin.readsome()可能会返回所有悬而未决的未处理的控制台输入,或可能总是返回零,并从中提取任何字符.
原文:
The behavior of this function is highly implementation-specific. For example, when used with std::ifstream, some compilers fill the underlying filebuf with data as soon as the file is opened (and readsome() on such compilers reads data, potentially, but not necessarily, the entire file), while other compilers only read from file when an actual input operation is requested (and readsome() issued after file opening never extracts any characters). Likewise, a call to std::cin.readsome() may return all pending unprocessed console input, or may always return zero and extract no characters.
[编辑] 参数
s | - | 指针指向的字符数组来存储的字符
原文: pointer to the character array to store the characters to |
count | - | 要读取的字符的最大数量
原文: maximum number of characters to read |
[编辑] 返回值
实际提取的字符数.
原文:
number of characters actually extracted.
[编辑] 示例
本章尚未完成 原因:暂无示例 |
[编辑] 另请参阅
提取的字符块 (公共成员函数) |