다음을 통해 공유


operator>> (<istream>)

스트림에서 문자 및 문자열을 추출합니다.

template<class Elem, class Tr>
    basic_istream<Elem, Tr>& operator>>(
        basic_istream<Elem, Tr>& _Istr, 
        Elem *_Str
    );
template<class Elem, class Tr>
    basic_istream<Elem, Tr>& operator>>(
        basic_istream<Elem, Tr>& _Istr, 
        Elem& _Ch
    );
template<class Tr>
    basic_istream<char, Tr>& operator>>(
        basic_istream<char, Tr>& _Istr, 
        signed char *_Str
    );
template<class Tr>
    basic_istream<char, Tr>& operator>>(
        basic_istream<char, Tr>& _Istr, 
        signed char& _Ch
    );
template<class Tr>
    basic_istream<char, Tr>& operator>>(
        basic_istream<char, Tr>& _Istr, 
        unsigned char *_Str
    );
template<class Tr>
    basic_istream<char, Tr>& operator>>(
        basic_istream<char, Tr>& _Istr, 
        unsigned char& _Ch
    );
template<class Elem, class Tr, class Type>
    basic_istream<Elem, Tr>& operator>>(
        basic_istream<char, Tr>&& _Istr,
        Type& _Val
    );

매개 변수

  • _Ch
    문자입니다.

  • _Istr
    스트림입니다.

  • _Str
    문자열

  • _Val
    한 종류입니다.

반환 값

스트림

설명

basic_istream 클래스도 여러 추출 연산자를 정의 합니다.자세한 내용은 basic_istream::operator>>를 참조하십시오.

템플릿 함수:

template<class Elem, class Tr>
   basic_istream<Elem, Tr>& operator>>(
      basic_istream<Elem, Tr>& _Istr, Elem *_Str);

최대 추출 N -1 요소에 _에서 시작 하 여 배열에 저장 하 고Str.If _Istr. 0 보다 크면 N 는 _Istr.width; 그렇지 않으면 큰 배열의 크기는 Elem 선언 될 수 있습니다.함수는 항상 값이 저장 Elem() 모든 저장 요소 추출 후.추출 중지 초기에 파일 끝 문자 값에 Elem(0) (어떤 되어 추출), 또는에 의해 삭제 됩니다 (추출 된) 모든 요소 ws.호출 함수 요소를 추출 하는 경우 _Istr. setstate(failbit).호출을 _Istr. (0)를 반환 하 고 _Istr.

보안 참고 는 null로 끝나는 문자열 입력된 스트림에서 압축을 풀 대상 버퍼 크기를 초과할 수 없습니다 _Str.자세한 내용은 버퍼 오버런 방지.

템플릿 함수:

template<class Elem, class Tr>
   basic_istream<Elem, Tr>& operator>>(
      basic_istream<Elem, Tr>& _Istr, Elem& _Ch);

가능 하 고 저장 하는 경우 요소, 추출 _Ch.그렇지 않으면 호출 . setstate(failbit).어떤 경우에 반환 _Istr.

템플릿 함수:

template<class Tr>
   basic_istream<char, Tr>& operator>>(
      basic_istream<char, Tr>& _Istr, signed char *_Str);

반환 _Istr >> (char*****)_Str.

템플릿 함수:

template<class Tr>
   basic_istream<char, Tr>& operator>>(
      basic_istream<char, Tr>& _Istr, signed char& _Ch);

반환 _Istr >> (char&)_Ch.

템플릿 함수:

template<class Tr>
   basic_istream<char, Tr>& operator>>(
      basic_istream<char, Tr>& _Istr, unsigned char *_Str);

반환 _Istr >> (char *)_Str.

템플릿 함수:

template<class Tr>
   basic_istream<char, Tr>& operator>>(
      basic_istream<char, Tr>& _Istr, unsigned char& _Ch);

반환 _Istr >> (char&)_Ch.

템플릿 함수:

template<class Elem, class Tr, class Type>
   basic_istream<Elem, Tr>& operator>>(
      basic_istream<char, Tr>&& _Istr,
      Type& _Val
   );

returns _Istr >> _Val (and converts an rvalue reference to _Istr to an lvalue in the process).

예제

// istream_op_extract.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;

int main( ) 
{
   ws( cin );
   char c[10];

   cin.width( 9 );
   cin >> c;
   cout << c << endl;
}

입력

1234567890

Output

12345678

요구 사항

헤더: <istream>

네임 스페이스: std

참고 항목

참조

basic_istream::operator>>

iostream 프로그래밍

iostreams 규칙