Bonjour à tous,
par plusieurs fois on a conseillé sur ce forum d'utiliser la fonction fgets() (en conjonction avec sscanf(), strtol(), strtod(), etc.) afin de sécuriser les entrée au clavier.
Dans ce contexte, je suis tombé sur ce tutoriel "The GNU C Programming Tutorial" http://www.crasseux.com/books/ctutorial/fgets.html#fgets qui donne à fgets() le status de fonction dépréciée comme gets():
Qu'en pensez-vous?The fgets ("file get string") function is similar to the gets function. This function is deprecated -- that means it is obsolete and it is strongly suggested you do not use it -- because it is dangerous. It is dangerous because if the input data contains a null character, you can't tell. Don't use fgets unless you know the data cannot contain a null. Don't use it to read files edited by the user because, if the user inserts a null character, you should either handle it properly or print a clear error message. Always use getline or getdelim instead of fgets if you can.
Meilleures salutations
Thierry
Partager