basic_istream::read
Reads a specified number of characters from the stream and stores them in an array.
This method is potentially unsafe, as it relies on the caller to check that the passed values are correct.
basic_istream<Elem, Tr>& read(
char_type *_Str,
streamsize _Count
);
매개 변수
_Str
The array in which to read the characters._Count
읽을 문자 수입니다.
반환 값
The stream (*this).
설명
The unformatted input function extracts up to count elements and stores them in the array beginning at _Str. Extraction stops early on end of file, in which case the function calls setstate(failbit). In any case, it returns *this.
예제
// basic_istream_read.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;
int main()
{
char c[10];
int count = 5;
cout << "Type 'abcde': ";
// Note: cin::read is potentially unsafe, consider
// using cin::_Read_s instead.
cin.read(&c[0], count);
c[count] = 0;
cout << c << endl;
}
abcde
FakePre-9b591a2a28734af2ae365d71e3fa59e1-e5c538edc2a1415f84e9740845c89550
요구 사항
Header: <istream>
네임스페이스: std