std::clearerr(3)
π¦ std::clearerr(3) β C++ Standard Libary π¦
okay so bestie, welcome to the std::clearerr(3) page β C++ Standard Library corner of the group chat, stream-cleanup edition π
β¨ NAME β¨
std::clearerr β and yes, the name is literally std::clearerr, no cap. That's the whole name section, periodt. π
πΈ Synopsis πΈ
Defined in header <cstdio> β¨
void clearerr( std::FILE* stream );
What it does: it resets the error flags and the EOF indicator for the given file stream. Lowkey the cleanup bestie for your stream's emotional baggage π
π Parameters π
streamβ the file to reset the error flags for. That's the whole parameter list, bestie. π«Ά
π Return value π
(none) β literally nothing comes back. No return value, no drama. π
π¦ Example π¦
Okay so here's the exact code from the page, run-it-yourself energy:
// Run this code
#include <cassert>
#include <cstdio>
int main()
{
std::FILE* tmpf = std::tmpfile();
std::fputs("cppreference.com\n", tmpf);
std::rewind(tmpf);
for (int ch; (ch = std::fgetc(tmpf)) != EOF; std::putchar(ch)) { }
assert(std::feof(tmpf)); // the loop is expected to terminate by
EOF
std::puts("End of file reached");
std::clearerr(tmpf); // clear EOF
std::puts(std::feof(tmpf) ? "EOF indicator set"
: "EOF indicator cleared");
}
π Output: π
cppreference.com
End of file reached
EOF indicator cleared
π See also π
feofβ checks for the end-of-file. It's a function. πperrorβ displays a character string corresponding of the current error tostderr. It's a function. π«Άferrorβ checks for a file error. It's a function. π- C documentation for
clearerrβ go read the C docs forclearerr, bestie. π¦
shoutout to http://cppreference.com, source/version date 2024.06.10, and that's the std::clearerr(3) page β periodt. πβ¨π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms