다음을 통해 공유


operator>>(<istream>)

Extracts characters and strings from the stream.

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
    A type.

반환 값

The stream

설명

The basic_istream class also defines several extraction operators. 자세한 내용은 basic_istream::operator>>을 참조하십시오.

The template function:

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

extracts up to N - 1 elements and stores them in the array starting at _Str. If _Istr.width is greater than zero, N is _Istr.width; otherwise, it is the size of the largest array of Elem that can be declared. The function always stores the value Elem() after any extracted elements it stores. Extraction stops early on end of file, on a character with value Elem(0) (which is not extracted), or on any element (which is not extracted) that would be discarded by ws. If the function extracts no elements, it calls _Istr.setstate(failbit). In any case, it calls _Istr.width(0) and returns _Istr.

Security Note The null-terminated string being extracted from the input stream must not exceed the size of the destination buffer _Str. 자세한 내용은 버퍼 오버런 방지를 참조하십시오.

The template function:

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

extracts an element, if it is possible, and stores it in _Ch. Otherwise, it calls is.setstate(failbit). In any case, it returns _Istr.

The template function:

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

returns _Istr >> (char *)_Str.

The template function:

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

returns _Istr >> (char&)_Ch.

The template function:

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

returns _Istr >> (char *)_Str.

The template function:

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

returns _Istr >> (char&)_Ch.

The template function:

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

요구 사항

Header: <istream>

네임스페이스: std

참고 항목

참조

basic_istream::operator>>

iostream 프로그래밍

iostreams 규칙