gets, gets_s
De cppreference.com
![]() | Esta página se ha traducido por ordenador/computador/computadora de la versión en inglés de la Wiki usando Google Translate. La traducción puede contener errores y palabras aparatosas/incorrectas. Planea sobre el texto para ver la versión original. Puedes ayudar a corregir los errores y mejorar la traducción. Para instrucciones haz clic aquí. |
Definido en el archivo de encabezado <stdio.h> | ||
char*gets(char*str ); | (hasta C11) | |
char*gets_s(char*str, rsize_t n); | (desde C11)(opcional) | |
1)
Lee stdin en la cadena de caracteres apuntada por
str
hasta que un carácter de nueva línea se encuentra o se produce al final de su archivo. AOriginal:
Reads stdin into the character array pointed to by
str
until a newline character is found or end-of-file occurs. AThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
carácter nulo es escrito inmediatamente después del último carácter leído en el array .
Original:
null character is written immediately after the last character read into the array.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
2)
Lee en la mayoría de los personajes de n-1stdin en el array apuntado por
str
hasta que la nueva línea de carácter, la condición de fin de archivo o error de lectura. Un carácter nulo es escrito inmediatamente después del último carácter leído en la matriz, o si no hay caracteres str[0] se leyeron .Original:
Reads at most n-1 characters from stdin into the array pointed to by
str
until new-line character, end-of-file condition, or read error. A null character is written immediately after the last character read into the array, or to str[0] if no characters were read.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
@ @ Si
n
es cero o es mayor que RSIZE_MAX, un carácter nulo se escribe en str[0] pero la función lee y descarta los caracteres de stdin hasta que la nueva línea de carácter, la condición de fin de archivo o error de lectura .Original:
@@ If
n
is zero or is greater than RSIZE_MAX, a null character is written to str[0] but the function reads and discards characters from stdin until new-line character, end-of-file condition, or read error.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
@ @ Si los caracteres
n-1
han sido leídos, continúa leyendo y descartando los personajes de stdin hasta la nueva línea de carácter, la condición de fin de archivo o error de lectura .Original:
@@ If
n-1
characters have been read, continues reading and discarding the characters from stdin until new-line character, end-of-file condition, or read error.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
@ @ La función
gets_s
es una extensión y es opcional. Está garantizado para estar presente sólo si se define __STDC_LIB_EXT1__ .Original:
@@ The
gets_s
function is an extension and is optional. It is guaranteed to be present only if __STDC_LIB_EXT1__ is defined.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Contenido |
[editar]Parámetros
str | - | cadena de caracteres a ser escrito Original: character string to be written 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
str
en caso de éxito, NULL lo contrarioOriginal:
str
on success, NULL otherwiseThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[editar]Notas
La función
gets()
no realiza una comprobación de límites, por lo que esta función es extremadamente vulnerable a los ataques de desbordamiento de búfer. No se puede utilizar de forma segura (a menos que el programa se ejecuta en un entorno que limita lo que puede aparecer en stdin
). Por esta razón, la función está desfasada y en la tercera corrección de la norma C99 y eliminado por completo en el estándar C11. fgets()
y gets_s()
son los reemplazos recomendadas .Original:
The
gets()
function does not perform bounds checking, therefore this function is extremely vulnerable to buffer-overflow attacks. It cannot be used safely (unless the program runs in an environment which restricts what can appear on stdin
). For this reason, the function has been deprecated in the third corrigendum to the C99 standard and removed altogether in the C11 standard. fgets()
and gets_s()
are the recommended replacements.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Nunca
gets()
usar .Original:
Never use
gets()
.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[editar]Ver también
lee la entrada con formato desde stdin, una secuencia de archivo o un tampón Original: reads formatted input from stdin, 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) | |
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) | |
escribe una cadena de caracteres en una secuencia de archivo Original: writes a character string to 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) | |
Documentación de C++ para gets |