Espaços nominais
Variantes
Acções

std::basic_istream::getline

Da cppreference.com
< cpp‎ | io‎ | basic istream

 
 
De entrada / saída da biblioteca
I / O manipuladores
C estilo de I / O
Buffers
Original:
Buffers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_streambuf
basic_filebuf
basic_stringbuf
strstreambuf(obsoleta)
Streams
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Abstrações
Original:
Abstractions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base
basic_ios
basic_istream
basic_ostream
basic_iostream
File I / O
Original:
File I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ifstream
basic_ofstream
basic_fstream
Cordas I / O
Original:
String I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istringstream
basic_ostringstream
basic_stringstream
Matriz de I / O
Original:
Array I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
istrstream(obsoleta)
ostrstream(obsoleta)
strstream(obsoleta)
Tipos
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
streamoff
streamsize
fpos
Interface de categoria de erro
Original:
Error category interface
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
iostream_category(C++11)
io_errc(C++11)
 
std::basic_istream
Objetos globais
Original:
Global objects
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
cin
wcin
Funções de membro
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istream::basic_istream
basic_istream::~basic_istream
basic_istream::operator=(C++11)
Entrada formatada
Original:
Formatted input
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istream::operator>>
Entrada não formatado
Original:
Unformatted input
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istream::get
basic_istream::peek
basic_istream::unget
basic_istream::putback
basic_istream::getline
basic_istream::ignore
basic_istream::read
basic_istream::readsome
basic_istream::gcount
Posicionamento
Original:
Positioning
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istream::tellg
basic_istream::seekg
Diversos
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istream::sync
basic_istream::swap(C++11)
Aulas-Membros
Original:
Member classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istream::sentry
Não-membros funções
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
operator>>(std::basic_istream)
 
basic_istream& getline( char_type* s, std::streamsize count );
(1)
basic_istream& getline( char_type* s, std::streamsize count, char_type delim );
(2)
1)
Extractos caracteres de corrente até que a extremidade da linha (equivalente a getline(s, count, widen(’\n’)))
Original:
Extracts characters from stream until the end of line (equivalent to getline(s, count, widen(’\n’)))
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
Extratos personagens de fluxo até o delimitador especificado.
Original:
Extracts characters from stream until the specified delimiter.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Se comporta como UnformattedInputFunction. Depois de construir e verificar o objeto de sentinela, extrai os caracteres de *this e armazenados-los em locais sucessivos da matriz cujo primeiro elemento é apontado por s até qualquer uma das seguintes situações: (testado na ordem mostrada)
Original:
Behaves as UnformattedInputFunction. After constructing and checking the sentry object, extracts characters from *this and stored them in successive locations of the array whose first element is pointed to by s until any of the following occurs: (tested in the order shown)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • condição de fim de arquivo ocorre na seqüência de entrada (no qual setstate(eofbit) caso é executado)
    Original:
    end of file condition occurs in the input sequence (in which case setstate(eofbit) is executed)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • o c próximo caracter disponível é o delimitador, conforme determinado pelo Traits::eq(c, delim). O delimitador é extraído (ao contrário basic_istream::get()) e contados para gcount(), mas não está armazenado.
    Original:
    the next available character c is the delimiter, as determined by Traits::eq(c, delim). The delimiter is extracted (unlike basic_istream::get()) and counted towards gcount(), but is not stored.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Caracteres count-1 foram extraídos (caso em que é executado setstate(failbit)).
    Original:
    count-1 characters have been extracted (in which case setstate(failbit) is executed).
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
Se a função não extrai caracteres (por exemplo, se count < 1), setstate(failbit) é executado.
Original:
If the function extracts no characters (e.g. if count < 1), setstate(failbit) is executed.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Em qualquer caso, se count>0, é, em seguida, armazena uma CharT() caractere nulo na próxima localização sucessiva da matriz e actualizações gcount().
Original:
In any case, if count>0, it then stores a null character CharT() into the next successive location of the array and updates gcount().
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Índice

[editar] Notas

Porque condição # 2 é testada antes condição # 3, a linha de entrada que se encaixa exactamente o tampão, não provoca failbit.
Original:
Because condition #2 is tested before condition #3, the input line that exactly fits the buffer, does not trigger failbit.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Porque o caractere de terminação é contado como personagem extraído, linha de entrada vazia não aciona failbit.
Original:
Because the terminating character is counted as extracted character, empty input line does not trigger failbit.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Parâmetros

s -
ponteiro para a cadeia de caracteres para armazenar os personagens
Original:
pointer to the character string to store the characters to
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
count -
tamanho da cadeia de caracteres apontada por s
Original:
size of character string pointed to by s
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
delim -
delimitando personagem para parar a extracção em. Extrai-se, mas não são armazenados .
Original:
delimiting character to stop the extraction at. It is extracted but not stored.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Valor de retorno

*this

[editar] Exemplo

#include <iostream>
#include <sstream>
#include <vector>
#include <array>
 
int main()
{
    std::istringstream input("abc|def|gh");
    std::vector<std::array<char, 4>> v;
 
    for(std::array<char, 4> a; input.getline(&a[0], 4, '|'); ) {
        v.push_back(a);
    }
 
    for(auto& a : v) {
        std::cout << &a[0] << '\n';
    }
}

Output:

abc
def
gh

[editar] Veja também

ler dados de um fluxo de I / O em uma string
Original:
read data from an I/O stream into a string
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função)
extratos dados formatados
Original:
extracts formatted data
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função pública membro) [edit]
extratos personagens
Original:
extracts characters
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função pública membro) [edit]
extrai blocos de caracteres
Original:
extracts blocks of characters
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função pública membro) [edit]