std::basic_istream::readsome
std::streamsize readsome( char_type* s, std::streamsize count ); |
||
Extracts immediately available characters from the input stream.
First, constructs a std::basic_istream::sentry object with noskipws set to true. Afterwards, if good()==false, calls setstate(failbit) and returns. Otherwise,
If rdbuf()->in_avail() == -1, calls setstate(eofbit) and extracts no characters.
If rdbuf()->in_avail() == 0, extracts no characters.
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.
Contents |
[edit] Notes
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.
[edit] Parameters
s | - | pointer to the character array to store the characters to |
count | - | maximum number of characters to read |
[edit] Return value
number of characters actually extracted.
[edit] Example
This section is incomplete Reason: no example |
[edit] See also
extracts blocks of characters (public member function) |