gets, gets_s
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody>| Déclaré dans l'en-tête <stdio.h>
|
||
char *gets( char *str ); |
||
char *gets_s(char *str, rsize_t n); |
(depuis C11) (en option) | |
1)
Lit stdin dans le tableau de caractères pointée par
str jusqu'à ce qu'un caractère de nouvelle ligne n'est trouvée ou fin de fichier est atteinte. 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.
caractère nul est écrit immédiatement après le dernier caractère lu dans le tableau .
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)
Lit à partir de la plupart des personnages
n-1 stdin dans le tableau pointé par str jusqu'au erreur un caractère nouvelle ligne, en fin de fichier condition, ou de lire. Un caractère nul est écrit immédiatement après le dernier caractère lu dans le tableau, ou si aucun caractère str[0] ont été lues .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 est égal à zéro ou est supérieure à RSIZE_MAX, un caractère nul est écrit str[0] mais la fonction lit et supprime les caractères de stdin jusqu'au erreur un caractère nouvelle ligne, en fin de fichier condition, ou lire .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 les caractères
n-1 ont été lues, la lecture continue et en écartant les personnages de stdin jusqu'à un caractère nouvelle ligne, en fin de fichier condition, ou erreur de lecture .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.
@ @ Fonction
gets_s Le est une extension et est facultative. Il est assuré d'être présent que si __STDC_LIB_EXT1__ est définie .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.
Paramètres
| str | - | chaîne de caractères à écrire
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. |
Retourne la valeur
str en cas de succès, NULL autrementOriginal:
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.
Notes
La fonction
gets() n'effectue pas la vérification des limites, par conséquent cette fonction est extrêmement vulnérable aux attaques par Buffer Overflow. Il ne peut pas être utilisé en toute sécurité (à moins que le programme s'exécute dans un environnement qui limite ce qui peut apparaître sur stdin). Pour cette raison, la fonction a été désapprouvée dans le corrigendum troisième à la norme C99 et enlevé tout à fait dans la norme C11. fgets() et gets_s() sont les remplacements recommandés .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.
Ne jamais utiliser ..
gets()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.
Voir aussi
lit l'entrée en forme à partir stdin, un flux de fichier ou un tampon 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. (fonction) | |
reçoit une chaîne de caractères à partir d'un flux de fichier 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. (fonction) | |
écrit une chaîne de caractères dans un flux fichier 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. (fonction) | |
C++ documentation for gets
| |