operator>> (<istream>)
Caratteri e stringhe di estratti dal flusso.
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
);
Parametri
_Ch
Carattere._Istr
Flusso specificato._Str
Stringa._Val
Un tipo.
Valore restituito
Il flusso
Note
La classe basic_istream definisce inoltre numerosi operatori di estrazione.Per ulteriori informazioni, vedere basic_istream::operator>>.
La funzione di modello:
template<class Elem, class Tr>
basic_istream<Elem, Tr>& operator>>(
basic_istream<Elem, Tr>& _Istr, Elem *_Str);
gli estratti fino a N elementi - 1 e li archivia nella matrice che iniziano dal _Str.Se _Istr.larghezza è maggiore di zero, N è _Istr.width; in caso contrario, la dimensione di più grande matrice Elem che possa essere dichiarata.La funzione memorizza sempre il valore Elem() dopo che tutti gli elementi che estrae i file.Le estrazioni interrompe nella fase iniziale di fine file, un carattere con valore Elem(0) (non viene estratto), o su qualsiasi elemento (non viene estratto) che verrà rimosso da la WS.Se la funzione non viene estratto elementi, chiama _Istr.setstate(failbit).Tuttavia, chiama _Istr.width(0) e restituisce _Istr.
Security Note la stringa con terminazione null che viene estratta dal flusso di input non deve superare la dimensione del buffer di destinazione _Str.Per ulteriori informazioni, vedere Evitare i sovraccarichi del buffer.
La funzione di modello:
template<class Elem, class Tr>
basic_istream<Elem, Tr>& operator>>(
basic_istream<Elem, Tr>& _Istr, Elem& _Ch);
estrae un elemento, se è possibile e lo archivia in _Ch.In caso contrario, chiama is.setstate(failbit).Tuttavia, restituisce _Istr.
La funzione di modello:
template<class Tr>
basic_istream<char, Tr>& operator>>(
basic_istream<char, Tr>& _Istr, signed char *_Str);
restituisce _Istr >> (char*****)_Str.
La funzione di modello:
template<class Tr>
basic_istream<char, Tr>& operator>>(
basic_istream<char, Tr>& _Istr, signed char& _Ch);
restituisce _Istr >> (char&)_Ch.
La funzione di modello:
template<class Tr>
basic_istream<char, Tr>& operator>>(
basic_istream<char, Tr>& _Istr, unsigned char *_Str);
restituisce _Istr >> (char *)_Str.
La funzione di modello:
template<class Tr>
basic_istream<char, Tr>& operator>>(
basic_istream<char, Tr>& _Istr, unsigned char& _Ch);
restituisce _Istr >> (char&)_Ch.
La funzione di modello:
template<class Elem, class Tr, class Type>
basic_istream<Elem, Tr>& operator>>(
basic_istream<char, Tr>&& _Istr,
Type& _Val
);
restituisce _Istr>>_Val (e convertiti rvalue reference a _Istr a lvalue nel processo).
Esempio
// 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;
}
Input
1234567890
Output
12345678
Requisiti
intestazione: <istream>
Spazio dei nomi: deviazione standard