void clearerr(FILE* stream);
It is defined in <cstdio> header file.
stream
: The file stream to reset the error flags and EOF indicator.
#include <iostream>
#include <cstdio>
using namespace std;
int main ()
{
int ch;
FILE* fp;
fp = fopen("file.txt","w");
if(fp)
{
ch = getc(fp);
if(ferror(fp))
{
cout << "Error set" << endl;
clearerr (fp);
}
}
if(!ferror(fp))
cout << "Error reset";
fclose (fp);
return 0;
}
When you run the program, the output will be:
Error set Error reset
Name | Views | Likes |
---|---|---|
C++ ftell() Function | 250 | 0 |
C++ fseek() Function | 478 | 0 |
C++ rewind() Function | 383 | 0 |
C++ vsprintf() Function | 199 | 0 |
C++ fgetc() Function | 286 | 0 |
C++ vsscanf() Function | 197 | 0 |
C++ putc() Function | 316 | 0 |
C++ fputc() Function | 265 | 0 |
C++ fread() Function | 237 | 0 |
C++ vsnprintf() Function | 379 | 0 |
C++ getc() Funcion | 227 | 0 |
C++ |
244 | 0 |
C++ fwrite() Function | 258 | 0 |
C++ fsetpos() Function | 200 | 0 |
C++ getchar() function | 475 | 0 |
C++ tmpnam() Function | 206 | 0 |
C++ ungetc() Function | 229 | 0 |
C++ fgetpos() Function | 205 | 0 |
C++ setbuf() Function | 189 | 0 |
C++ fputs() Function | 238 | 0 |
C++ fclose() Function | 281 | 0 |
C++ Clearerr() Function | 231 | 0 |
C++ fgets() Function | 258 | 0 |
C++ Remove() Function | 251 | 0 |
Comments