operator>> (<istream>)
Extrahuje znaky a řetězce z datového proudu.
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
);
Parametry
_Ch
Znak._Istr
Datový proud._Str
Řetězec._Val
Typ.
Vrácená hodnota
Datový proud
Poznámky
basic_istream Třída definuje také několik operátorů extrakce.Další informace naleznete v tématu basic_istream::operator>>.
Funkce šablony:
template<class Elem, class Tr>
basic_istream<Elem, Tr>& operator>>(
basic_istream<Elem, Tr>& _Istr, Elem *_Str);
až se extrahuje N - 1 prvky a ukládá je v matici počínaje _Str.If _Istr. Šířka je větší než nula, N je _Istr.width; v ostatních případech je velikost největší pole Elem mohou být deklarovány.Funkce vždy uložena hodnota Elem() po některé prvky ukládá extrahovány.Extrakce brzy zastaví na konec souboru, na znak s hodnotou Elem(0) (která není extrahovat), nebo na jakýkoli element (který není extrahovat), která by jím ws.Pokud funkce extrahuje žádné prvky, volá _Istr. setstate(failbit).V každém případě volá _Istr. Šířka(0) a vrátí _Istr.
Poznámka: zabezpečení řetězec zakončený hodnotou null, jsou extrahovány z vstupní proud nesmí překročit velikost cílové vyrovnávací paměti _Str.Další informace naleznete v tématu Předcházení přetečení vyrovnávací paměti.
Funkce šablony:
template<class Elem, class Tr>
basic_istream<Elem, Tr>& operator>>(
basic_istream<Elem, Tr>& _Istr, Elem& _Ch);
Vybere element, pokud je to možné a uloží jej v _Ch.V opačném případě se volá je. setstate(failbit).V každém případě, vrátí _Istr.
Funkce šablony:
template<class Tr>
basic_istream<char, Tr>& operator>>(
basic_istream<char, Tr>& _Istr, signed char *_Str);
returns _Istr>> (char *)_Str.
Funkce šablony:
template<class Tr>
basic_istream<char, Tr>& operator>>(
basic_istream<char, Tr>& _Istr, signed char& _Ch);
returns _Istr>> (char&)_Ch.
Funkce šablony:
template<class Tr>
basic_istream<char, Tr>& operator>>(
basic_istream<char, Tr>& _Istr, unsigned char *_Str);
returns _Istr>> (char *)_Str.
Funkce šablony:
template<class Tr>
basic_istream<char, Tr>& operator>>(
basic_istream<char, Tr>& _Istr, unsigned char& _Ch);
returns _Istr>> (char&)_Ch.
Funkce šablony:
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).
Příklad
// 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;
}
Vstup
1234567890
Výsledek
12345678
Požadavky
Záhlaví:<istream>
Obor názvů: std