clearerr
From cppreference.net
File input/output
| Types and objects | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Definido en el encabezado
<stdio.h>
|
||
|
void
clearerr
(
FILE
*
stream
)
;
|
||
Restablece los indicadores de error y el
EOF
para el flujo de archivo dado.
Contenidos |
Parámetros
| stream | - | el archivo para restablecer las banderas de error |
Valor de retorno
(ninguno)
Ejemplo
Ejecutar este código
#include <stdio.h> #include <assert.h> int main(void) { FILE* tmpf = tmpfile(); fputs("cppreference.net\n", tmpf); rewind(tmpf); for (int ch; (ch = fgetc(tmpf)) != EOF; putchar(ch)) { } assert(feof(tmpf)); // the loop is expected to terminate by EOF puts("End of file reached"); clearerr(tmpf); // clear EOF puts(feof(tmpf) ? "EOF indicator set" : "EOF indicator cleared"); }
Salida:
cppreference.net End of file reached EOF indicator cleared
Referencias
- Estándar C17 (ISO/IEC 9899:2018):
-
- 7.21.10.1 La función clearerr (p: 246)
- Estándar C11 (ISO/IEC 9899:2011):
-
- 7.21.10.1 La función clearerr (p: 338)
- Estándar C99 (ISO/IEC 9899:1999):
-
- 7.19.10.1 La función clearerr (p: 304)
- Estándar C89/C90 (ISO/IEC 9899:1990):
-
- 4.9.10.1 La función clearerr
Véase también
|
comprueba el fin de archivo
(función) |
|
|
muestra una cadena de caracteres correspondiente al error actual en
stderr
(función) |
|
|
comprueba un error de archivo
(función) |
|
|
C++ documentation
para
clearerr
|
|