From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/c/io%2Fclearerr.html | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 devdocs/c/io%2Fclearerr.html (limited to 'devdocs/c/io%2Fclearerr.html') diff --git a/devdocs/c/io%2Fclearerr.html b/devdocs/c/io%2Fclearerr.html new file mode 100644 index 00000000..0b82bfed --- /dev/null +++ b/devdocs/c/io%2Fclearerr.html @@ -0,0 +1,45 @@ +

clearerr

Defined in header <stdio.h>
void clearerr( FILE *stream );
+

Resets the error flags and the EOF indicator for the given file stream.

+

Parameters

+ +
stream - the file to reset the error flags for

Return value

(none)

+

Example

#include <stdio.h>
+#include <assert.h>
+ 
+int main(void)
+{
+    FILE* tmpf = tmpfile();
+    fputs("cppreference.com\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");
+}

Output:

+
cppreference.com
+End of file reached
+EOF indicator cleared

References

See also

+ + + +
checks for the end-of-file
(function)
displays a character string corresponding of the current error to stderr
(function)
checks for a file error
(function)
C++ documentation for clearerr
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/io/clearerr +

+
-- cgit v1.2.3