Espaços nominais
Variantes
Acções

std::scanf, std::fscanf, std::sscanf

Da cppreference.com
< cpp‎ | io‎ | c

 
 
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.
(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.
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.
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.
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.
(obsoleta)
(obsoleta)
(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.
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.
(C++11)
 
C estilo de I / O
Funções
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Arquivo de acesso
Original:
File access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Directa de entrada / saída
Original:
Direct input/output
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Não formatado entrada / saída
Original:
Unformatted input/output
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Formatado de entrada / saída
Original:
Formatted input/output
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
scanffscanfsscanf
(C++11)(C++11)(C++11)
Arquivo de posicionamento
Original:
File positioning
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
De tratamento de erros
Original:
Error handling
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Operações em arquivos
Original:
Operations on files
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
Definido no cabeçalho <cstdio>
int scanf( const char *format, ... );
(1)
int fscanf( FILE *stream, const char *format, ... );
(2)
int sscanf( const char *buffer, const char *format, ... );
(3)
Lê os dados do uma variedade de fontes, interpreta-o de acordo com format e armazena os resultados em determinados locais.
Original:
Reads data from the a variety of sources, interprets it according to format and stores the results into given locations.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1)
Lê os dados a partir de stdin
Original:
Reads the data from stdin
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
Lê os dados do stream fluxo de arquivo
Original:
Reads the data from file stream stream
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
Lê os dados terminada em nulo buffer cadeia de caracteres
Original:
Reads the data from null-terminated character string buffer
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Índice

[editar] Parâmetros

stream -
fluxo de arquivo de entrada para ler
Original:
input file stream to read from
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
buffer -
ponteiro para uma cadeia de caracteres terminada em nulo para ler
Original:
pointer to a null-terminated character string to read from
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
format -
ponteiro para uma cadeia de caracteres NULL-Terminated especificando como ler a entrada.
A cadeia de formato consiste de caracteres em branco (qualquer caractere único espaço em branco na string de formato consome todos os disponíveis caracteres consecutivos de espaço em branco da entrada), não-branco personagens, exceto % (cada personagem como nas seqüências de formato consome exatamente um personagem idêntico a partir da entrada) e especificações de conversão. Cada especificação de conversão tem o seguinte formato:
Original:
The format string consists of whitespace characters (any single whitespace character in the format string consumes all available consecutive whitespace characters from the input), non-whitespace characters except % (each such character in the format strings consumes exactly one identical character from the input) and conversion specifications. Each conversion specification has the following format:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • % caráter introdutório
    Original:
    introductory % character
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • (opcional) atribuição de supressão * personagem. Se esta opção estiver presente, a função não atribuir o resultado da conversão de um argumento de recepção.
    Original:
    (opcional) assignment-suppressing character *. If this option is present, the function does not assign the result of the conversion to any receiving argument.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • (opcional) número inteiro (maior do que zero), que especifica' largura máxima de campo, isto é, o número máximo de caracteres que a função é permitido consumir ao fazer a conversão especificado pela especificação de conversão de corrente. Note-se que [% s% e pode levar a um estouro de buffer, se a largura não é fornecido.
    Original:
    (opcional) integer number (greater than zero) that specifies maximum field width, that is, the maximum number of characters that the function is allowed to consume when doing the conversion specified by the current conversion specification. Note that %s and %[ may lead to buffer overflow if the width is not provided.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • (opcional)' modificador de comprimento que especifica o tamanho do argumento de recepção, isto é, o tipo de destino actual. Isso afeta a precisão de conversão e regras de estouro. O tipo de destino padrão é diferente para cada tipo de conversão (ver tabela abaixo).
    Original:
    (opcional) length modifier that specifies the size of the receiving argument, that is, the actual destination type. This affects the conversion accuracy and overflow rules. The default destination type is different for each conversion type (see table below).
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • formato de conversão especificador
    Original:
    conversion format specifier
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
Os especificadores de formato disponíveis são:
Original:
The following format specifiers are available:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Conversion
specifier
Explanation Argument type
length modifier hh h (none) l ll j z t L
% matches literal % N/A N/A N/A N/A N/A N/A N/A N/A N/A
c matches a single character N/A N/A
char*
wchar_t*
N/A N/A N/A N/A N/A
s matches a character string (a sequence of non-whitespace characters)
[set]
corresponde a uma seqüência não-vazia de personagem de set de caracteres.
Original:
matches a non-empty sequence of character from set of characters.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Se o primeiro caractere do conjunto é ^, então todos os personagens não no conjunto são correspondidos. Se o conjunto começa com ] ^] ou então o carácter ] também está incluído no conjunto de.
Original:
If the first character of the set is ^, then all characters not in the set are matched. If the set begins with ] or ^] then the ] character is also included into the set.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
d
combina inteiro decimal' a.
Original:
matches a decimal integer'.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
O formato do número é o mesmo que o esperado por strtol() com o 10 valor para o argumento base
Original:
The format of the number is the same as expected by strtol() with the value 10 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
signed char* or unsigned char*
signed short* or unsigned short*
signed int* or unsigned int*
signed long* or unsigned long*
signed long long* or unsigned long long*
intmax_t* or uintmax_t*
size_t*
ptrdiff_t*
N/A
i
combina inteiro decimal' a.
Original:
matches a decimal integer'.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
O formato do número é o mesmo que o esperado por strtol() com o 0 valor para o argumento base
Original:
The format of the number is the same as expected by strtol() with the value 0 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
u
combina inteiro decimal sem sinal' a.
Original:
matches a unsigned decimal integer'.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
O formato do número é o mesmo que o esperado por strtoul() com o 0 valor para o argumento base
Original:
The format of the number is the same as expected by strtoul() with the value 0 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
o
corresponde a uma 'inteiro octal'.
Original:
matches an octal integer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
O formato do número é o mesmo que o esperado por strtol() com o 8 valor para o argumento base
Original:
The format of the number is the same as expected by strtol() with the value 8 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
x
combina inteiro hexadecimal' um.
Original:
matches an hexadecimal integer'.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
O formato do número é o mesmo que o esperado por strtol() com o 16 valor para o argumento base
Original:
The format of the number is the same as expected by strtol() with the value 16 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
n
retorna 'número de caracteres lidos até agora' o.
Original:
returns the number of characters read so far.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Nenhuma entrada é consumida. Não incrementa a contagem de atribuição. Se o especificador tem a atribuição de supressão operador definido, o comportamento é indefinido
Original:
No input is consumed. Does not increment the assignment count. If the specifier has assignment-suppressing operator defined, the behavior is undefined
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
a, A
e, E
f, F
g, G
combina 'número de ponto flutuante' um.
Original:
matches a floating-point number.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
O formato do número é o mesmo que o esperado por strtof()
Original:
The format of the number is the same as expected by strtof()
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A N/A
float*
double*
N/A N/A N/A N/A
long double*
p
corresponde implementação seqüência de caracteres definidos definir um 'ponteiro'.
Original:
matches implementation defined character sequence defining a pointer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
printf família de funções deve produzir a mesma seqüência usando %p especificador de formato
Original:
printf family of functions should produce the same sequence using %p format specifier
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A N/A
void**
N/A N/A N/A N/A N/A N/A
Original:
pointer to a null-terminated character string specifying how to read the input.
A cadeia de formato consiste de caracteres em branco (qualquer caractere único espaço em branco na string de formato consome todos os disponíveis caracteres consecutivos de espaço em branco da entrada), não-branco personagens, exceto % (cada personagem como nas seqüências de formato consome exatamente um personagem idêntico a partir da entrada) e especificações de conversão. Cada especificação de conversão tem o seguinte formato:
Original:
The format string consists of whitespace characters (any single whitespace character in the format string consumes all available consecutive whitespace characters from the input), non-whitespace characters except % (each such character in the format strings consumes exactly one identical character from the input) and conversion specifications. Each conversion specification has the following format:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • % caráter introdutório
    Original:
    introductory % character
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • (opcional) atribuição de supressão * personagem. Se esta opção estiver presente, a função não atribuir o resultado da conversão de um argumento de recepção.
    Original:
    (opcional) assignment-suppressing character *. If this option is present, the function does not assign the result of the conversion to any receiving argument.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • (opcional) número inteiro (maior do que zero), que especifica' largura máxima de campo, isto é, o número máximo de caracteres que a função é permitido consumir ao fazer a conversão especificado pela especificação de conversão de corrente. Note-se que [% s% e pode levar a um estouro de buffer, se a largura não é fornecido.
    Original:
    (opcional) integer number (greater than zero) that specifies maximum field width, that is, the maximum number of characters that the function is allowed to consume when doing the conversion specified by the current conversion specification. Note that %s and %[ may lead to buffer overflow if the width is not provided.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • (opcional)' modificador de comprimento que especifica o tamanho do argumento de recepção, isto é, o tipo de destino actual. Isso afeta a precisão de conversão e regras de estouro. O tipo de destino padrão é diferente para cada tipo de conversão (ver tabela abaixo).
    Original:
    (opcional) length modifier that specifies the size of the receiving argument, that is, the actual destination type. This affects the conversion accuracy and overflow rules. The default destination type is different for each conversion type (see table below).
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • formato de conversão especificador
    Original:
    conversion format specifier
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
Os especificadores de formato disponíveis são:
Original:
The following format specifiers are available:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Conversion
specifier
Explanation Argument type
length modifier hh h (none) l ll j z t L
% matches literal % N/A N/A N/A N/A N/A N/A N/A N/A N/A
c matches a single character N/A N/A
char*
wchar_t*
N/A N/A N/A N/A N/A
s matches a character string (a sequence of non-whitespace characters)
[set]
corresponde a uma seqüência não-vazia de personagem de set de caracteres.
Original:
matches a non-empty sequence of character from set of characters.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Se o primeiro caractere do conjunto é ^, então todos os personagens não no conjunto são correspondidos. Se o conjunto começa com ] ^] ou então o carácter ] também está incluído no conjunto de.
Original:
If the first character of the set is ^, then all characters not in the set are matched. If the set begins with ] or ^] then the ] character is also included into the set.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
d
combina inteiro decimal' a.
Original:
matches a decimal integer'.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
O formato do número é o mesmo que o esperado por strtol() com o 10 valor para o argumento base
Original:
The format of the number is the same as expected by strtol() with the value 10 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
signed char* or unsigned char*
signed short* or unsigned short*
signed int* or unsigned int*
signed long* or unsigned long*
signed long long* or unsigned long long*
intmax_t* or uintmax_t*
size_t*
ptrdiff_t*
N/A
i
combina inteiro decimal' a.
Original:
matches a decimal integer'.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
O formato do número é o mesmo que o esperado por strtol() com o 0 valor para o argumento base
Original:
The format of the number is the same as expected by strtol() with the value 0 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
u
combina inteiro decimal sem sinal' a.
Original:
matches a unsigned decimal integer'.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
O formato do número é o mesmo que o esperado por strtoul() com o 0 valor para o argumento base
Original:
The format of the number is the same as expected by strtoul() with the value 0 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
o
corresponde a uma 'inteiro octal'.
Original:
matches an octal integer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
O formato do número é o mesmo que o esperado por strtol() com o 8 valor para o argumento base
Original:
The format of the number is the same as expected by strtol() with the value 8 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
x
combina inteiro hexadecimal' um.
Original:
matches an hexadecimal integer'.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
O formato do número é o mesmo que o esperado por strtol() com o 16 valor para o argumento base
Original:
The format of the number is the same as expected by strtol() with the value 16 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
n
retorna 'número de caracteres lidos até agora' o.
Original:
returns the number of characters read so far.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Nenhuma entrada é consumida. Não incrementa a contagem de atribuição. Se o especificador tem a atribuição de supressão operador definido, o comportamento é indefinido
Original:
No input is consumed. Does not increment the assignment count. If the specifier has assignment-suppressing operator defined, the behavior is undefined
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
a, A
e, E
f, F
g, G
combina 'número de ponto flutuante' um.
Original:
matches a floating-point number.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
O formato do número é o mesmo que o esperado por strtof()
Original:
The format of the number is the same as expected by strtof()
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A N/A
float*
double*
N/A N/A N/A N/A
long double*
p
corresponde implementação seqüência de caracteres definidos definir um 'ponteiro'.
Original:
matches implementation defined character sequence defining a pointer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
printf família de funções deve produzir a mesma seqüência usando %p especificador de formato
Original:
printf family of functions should produce the same sequence using %p format specifier
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A N/A
void**
N/A N/A N/A N/A N/A N/A
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
... -
receber argumentos
Original:
receiving arguments
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

Número de receber argumentos atribuído com sucesso, ou se EOF falha de leitura ocorre antes do primeiro argumento foi atribuído a receber.
Original:
Number of receiving arguments successfully assigned, or EOF if read failure occurs before the first receiving argument was assigned.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Exemplo

[editar] Veja também

(C++11)
(C++11)
(C++11)
lê entrada formatada de stdin, um fluxo de arquivo ou um buffer
usando lista de argumentos variável
Original:
reads formatted input from stdin, a file stream or a buffer
using variable argument list
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função) [edit]
recebe uma cadeia de caracteres a partir de um fluxo de arquivo
Original:
gets a character string from a file stream
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função) [edit]
impressões saída formatada para stdout, um fluxo de arquivo ou um tampão
Original:
prints formatted output to stdout, a file stream or a buffer
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função) [edit]
Documentação C para scanf, fscanf, sscanf