std:: clearerr
From cppreference.net
C++
Input/output library
| I/O manipulators | ||||
| Print functions (C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(C++20)
|
||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
| Synchronized Output | ||||
|
(C++20)
|
||||
| Types | ||||
| Error category interface | ||||
|
(C++11)
|
||||
|
(C++11)
|
C-style I/O
| Types and objects | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Défini dans l'en-tête
<cstdio>
|
||
|
void
clearerr
(
std::
FILE
*
stream
)
;
|
||
Réinitialise les indicateurs d'erreur et l'indicateur
EOF
pour le flux de fichier donné.
Table des matières |
Paramètres
| stream | - | le fichier pour lequel réinitialiser les indicateurs d'erreur |
Valeur de retour
(aucun)
Exemple
Exécuter ce code
#include <cassert> #include <cstdio> int main() { std::FILE* tmpf = std::tmpfile(); std::fputs("cppreference.net\n", tmpf); std::rewind(tmpf); for (int ch; (ch = std::fgetc(tmpf)) != EOF; std::putchar(ch)) { } assert(std::feof(tmpf)); // la boucle devrait se terminer par EOF std::puts("Fin de fichier atteinte"); std::clearerr(tmpf); // effacer EOF std::puts(std::feof(tmpf) ? "Indicateur EOF défini" : "Indicateur EOF effacé"); }
Sortie :
cppreference.net Fin de fichier atteinte Indicateur EOF effacé
Voir aussi
|
vérifie la fin de fichier
(fonction) |
|
|
affiche une chaîne de caractères correspondant à l'erreur courante vers
stderr
(fonction) |
|
|
vérifie une erreur de fichier
(fonction) |
|
|
Documentation C
pour
clearerr
|
|