#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
int i, n;
double d;
string str;
ifstream fin("test.dat");
if(!fin) {
cout << "Cannot open file.\n";
return 1;
}
fin >> i;
fin >> n;
fin >> d;
fin >> str;
fin.close();
if(!fin.good()) {
cout << "A file error occurred.";
return 1;
}
cout << i << " " << n << " " << d << " " << str << "\n";
return 0;
}
|