Espacios de nombres
Variantes
Acciones

scanf, fscanf, sscanf

De cppreference.com
< c‎ | io
 
 
File input/output
Funciones
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Acceso a archivos
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.
Directo de entrada / salida
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.
Entrada sin formato / salida
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.
Formato de entrada / salida
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.
Presentar posicionamiento
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.
Gestión de errores
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.
Las operaciones en los archivos
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 en el archivo de encabezado <stdio.h>
int scanf(constchar*format, ... );
(1)
int fscanf(FILE*stream, constchar*format, ... );
(2)
int sscanf(constchar*buffer, constchar*format, ... );
(3)
Lee los datos de la variedad una de las fuentes, se interpreta de acuerdo con format y almacena los resultados en localizaciones dadas .
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)
lee los datos 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)
lee los datos de stream archivo continuo
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)
lee los datos de terminación nula buffer cadena 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.

Contenido

[editar]Parámetros

stream -
flujo de entrada de archivo para leer
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 -
puntero a una cadena de caracteres terminada en cero que leer
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 -
puntero a una cadena de caracteres terminada en cero que especifica cómo leer la entrada.
La cadena de formato se compone de espacios en blanco (cualquier carácter único espacio en blanco en la cadena de formato consume todos los caracteres de espacio en blanco consecutivos a partir de la entrada), no está en blanco, excepto % personajes (cada personaje tal en las cadenas de formato consume exactamente un carácter idéntico de la entrada) y especificaciones de conversión. Cada especificación de conversión tiene el siguiente 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ácter introductorio
    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) asignación que suprime el carácter *. Si esta opción está presente, la función no se asigna el resultado de la conversión a cualquier argumento recepción .
    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 entero (mayor que cero) que especifica' máximo ancho de campo, es decir, el número máximo de caracteres que la función se les permitió consumir al hacer la conversión especificada por la especificación de conversión de corriente. Tenga en cuenta que [% s y% puede dar lugar al desbordamiento del búfer si el ancho no está previsto .
    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) longitud' modificador que especifica el tamaño del argumento de recepción, es decir, el tipo de destino real. Esto afecta a la precisión de la conversión y las reglas de desbordamiento. El tipo de destino predeterminado es diferente para cada tipo de conversión (ver tabla a continuación) .
    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.
  • conversión de formato 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.
Los especificadores de formato disponibles son las siguientes:
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 hhh (none) llljztL
% matches literal %N/AN/AN/AN/AN/AN/AN/AN/AN/A
c matches a single characterN/AN/A
char*
wchar_t*
N/AN/AN/AN/AN/A
s matches a character string (a sequence of non-whitespace characters)
[set]
coincide con una secuencia no vacía de caracteres 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.
Si el primer carácter del conjunto es ^, todos los caracteres en el conjunto no coinciden. Si el conjunto comienza con ] o ^] entonces el carácter ] también se incluye en el conjunto .
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
coincide con 'entero decimal' un .
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.
El formato del número es el mismo como se esperaba por strtol() con la 10 valor para el 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.
signedchar* or unsignedchar*
signedshort* or unsignedshort*
signedint* or unsignedint*
signedlong* or unsignedlong*
signedlonglong* or unsignedlonglong*
N/A
i
coincide con 'entero decimal' un .
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.
El formato del número es el mismo como se esperaba por strtol() con la 0 valor para el 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
coincide con un entero sin signo decimal' .
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.
El formato del número es el mismo como se esperaba por strtoul() con la 0 valor para el 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
coincide con una 'octal entero' .
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.
El formato del número es el mismo como se esperaba por strtol() con la 8 valor para el 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
coincide con 'entero hexadecimal' una .
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.
El formato del número es el mismo como se esperaba por strtol() con la 16 valor para el 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
devuelve 'número de caracteres leídos hasta el momento' del .
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.
Sin entrada se consume. No incrementar el recuento de asignación. Si el especificador de asignación tiene que suprime el operador definido, el comportamiento no está definido
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
coincide con un 'número de punto flotante' .
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.
El formato del número es el mismo como se esperaba 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/AN/A
float*
double*
N/AN/AN/AN/A
longdouble*
p
coincide con la aplicación definida secuencia de caracteres que define un 'puntero del' .
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 familia de funciones debe producir la misma secuencia utilizando especificador de formato %p
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/AN/A
void**
N/AN/AN/AN/AN/AN/A
Original:
pointer to a null-terminated character string specifying how to read the input.
La cadena de formato se compone de espacios en blanco (cualquier carácter único espacio en blanco en la cadena de formato consume todos los caracteres de espacio en blanco consecutivos a partir de la entrada), no está en blanco, excepto % personajes (cada personaje tal en las cadenas de formato consume exactamente un carácter idéntico de la entrada) y especificaciones de conversión. Cada especificación de conversión tiene el siguiente 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ácter introductorio
    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) asignación que suprime el carácter *. Si esta opción está presente, la función no se asigna el resultado de la conversión a cualquier argumento recepción .
    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 entero (mayor que cero) que especifica' máximo ancho de campo, es decir, el número máximo de caracteres que la función se les permitió consumir al hacer la conversión especificada por la especificación de conversión de corriente. Tenga en cuenta que [% s y% puede dar lugar al desbordamiento del búfer si el ancho no está previsto .
    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) longitud' modificador que especifica el tamaño del argumento de recepción, es decir, el tipo de destino real. Esto afecta a la precisión de la conversión y las reglas de desbordamiento. El tipo de destino predeterminado es diferente para cada tipo de conversión (ver tabla a continuación) .
    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.
  • conversión de formato 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.
Los especificadores de formato disponibles son las siguientes:
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 hhh (none) llljztL
% matches literal %N/AN/AN/AN/AN/AN/AN/AN/AN/A
c matches a single characterN/AN/A
char*
wchar_t*
N/AN/AN/AN/AN/A
s matches a character string (a sequence of non-whitespace characters)
[set]
coincide con una secuencia no vacía de caracteres 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.
Si el primer carácter del conjunto es ^, todos los caracteres en el conjunto no coinciden. Si el conjunto comienza con ] o ^] entonces el carácter ] también se incluye en el conjunto .
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
coincide con 'entero decimal' un .
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.
El formato del número es el mismo como se esperaba por strtol() con la 10 valor para el 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.
signedchar* or unsignedchar*
signedshort* or unsignedshort*
signedint* or unsignedint*
signedlong* or unsignedlong*
signedlonglong* or unsignedlonglong*
N/A
i
coincide con 'entero decimal' un .
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.
El formato del número es el mismo como se esperaba por strtol() con la 0 valor para el 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
coincide con un entero sin signo decimal' .
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.
El formato del número es el mismo como se esperaba por strtoul() con la 0 valor para el 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
coincide con una 'octal entero' .
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.
El formato del número es el mismo como se esperaba por strtol() con la 8 valor para el 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
coincide con 'entero hexadecimal' una .
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.
El formato del número es el mismo como se esperaba por strtol() con la 16 valor para el 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
devuelve 'número de caracteres leídos hasta el momento' del .
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.
Sin entrada se consume. No incrementar el recuento de asignación. Si el especificador de asignación tiene que suprime el operador definido, el comportamiento no está definido
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
coincide con un 'número de punto flotante' .
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.
El formato del número es el mismo como se esperaba 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/AN/A
float*
double*
N/AN/AN/AN/A
longdouble*
p
coincide con la aplicación definida secuencia de caracteres que define un 'puntero del' .
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 familia de funciones debe producir la misma secuencia utilizando especificador de formato %p
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/AN/A
void**
N/AN/AN/AN/AN/AN/A
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
... -
recibir 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 recibir argumentos con éxito corresponda o EOF si el fallo se produce antes de la lectura primer argumento recibido fue asignado .
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]Ejemplo

[editar]Ver también

(C99)(C99)(C99)
lee la entrada con formato de stdin, una secuencia de archivo o una buffer
con lista de argumentos variable
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.

(función)[editar]
recibe una cadena de caracteres a partir de una secuencia de archivo
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.

(función)[editar]
imprime la salida formateada para stdout, una secuencia de archivo o un tampón
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.

(función)[editar]
Documentación de C++ para scanf, fscanf, sscanf
close