ios::clear
void clear ( iostate state = goodbit ); | ios |
cplusplus.com |
Set control states.
Sets a new value for the control state ignoring the existing value.
Parameters.
Return Value.
none
Example.
// clearing errors
#include <iostream>
#include <fstream>
using namespace std;
int main () {
char buffer [80];
fstream myfile;
myfile.open ("test.txt",fstream::in);
myfile << "test";
if (myfile.fail())
{
cout << "Error writing to test.txt\n";
myfile.clear();
}
myfile.getline (buffer,80);
cout << buffer << " successfully read from file.\n";
return 0;
}
In this example myfile is open for input operations, but we commit
an output operation on it, so failbit is set.
The example calls then clear in order that
further operations like getline can be successfully
performed on myfile.
Basic template member declaration ( basic_ios<charT,traits> ):
void clear ( iostate state = goodbit ); |
See also.
fail,
good,
bad,
eof,
rdstate
ios class