M
Marco
Hi,
in the following code I get an error message after the file is output. What
did I do wrong?
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main() {
ifstream fileIn;
fileIn.exceptions ( ifstream::failbit | ifstream::badbit );
try {
fileIn.open( "file" ); }
catch ( ifstream::failure e ) {
cout << "Error."; }
string line;
while ( getline( fileIn, line ) ) {
cout << line << endl;
}
fileIn.close();
return 0;
}
The error message after the output of »file« is:
terminate called after throwing an instance of 'std::ios_base::failure'
what(): basic_ios::clear
Aborted
Regards
Marco
in the following code I get an error message after the file is output. What
did I do wrong?
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main() {
ifstream fileIn;
fileIn.exceptions ( ifstream::failbit | ifstream::badbit );
try {
fileIn.open( "file" ); }
catch ( ifstream::failure e ) {
cout << "Error."; }
string line;
while ( getline( fileIn, line ) ) {
cout << line << endl;
}
fileIn.close();
return 0;
}
The error message after the output of »file« is:
terminate called after throwing an instance of 'std::ios_base::failure'
what(): basic_ios::clear
Aborted
Regards
Marco