Espaços nominais
Variantes
Acções

scanf, fscanf, sscanf

Da cppreference.com
< c‎ | io

 
 
File input/output
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.
fread
fwrite
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.
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.
ftell
fgetpos
fseek
fsetpos
rewind
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.
clearerr
feof
ferror
perror
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.
remove
rename
tmpfile
tmpnam
 
Defined in header <stdio.h>
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*
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*
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

(C99)
(C99)
(C99)
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]
C++ documentation for scanf, fscanf, sscanf