basic_istream::_Readsome_s
Read from buffer only.
streamsize _Readsome_s(
char_type *_Str,
size_t _Str_size,
streamsize _Count
);
Parameters
_Str
The array in which to read the characters._Str_size
The size of _Str._Count
The number of characters to read.
Return Value
The count of items in the buffer.
Remarks
The unformatted input function extracts up to count elements and stores them in the array beginning at _Str. If good is false, the function calls setstate(failbit). Otherwise, it assigns the value of rdbuf->in_avail to N. If N < 0, the function calls setstate(eofbit). Otherwise, it replaces the value stored in N with the smaller of _Count and N, and then calls read(_Str, N). In any case, the function returns gcount.
Example
// basic_istream__Readsome_s.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;
int main( )
{
const int c_size = 10;
char c[c_size];
int count = 5;
cout << "Type 'abcdefgh': ";
// Can read from buffer or console
cin._Read_s(&c[0], c_size, 2);
// Can only read from buffer, not from console
cin._Readsome_s(&c[0], c_size, count);
c[count] = 0;
cout << c << endl;
}
Input
abcdefgh
Sample Output
Type 'abcdefgh': abcdefgh
cdefg
Requirements
Header: <istream>
Namespace: std