I/O issue

So i am trying to read some files and it works until a certian file in which it fails and files following fails. The name starts at
2011-11-11_0100.csv
It gets all the files between then and
2011-11-11_0200.csv
but the next file fails even though the program has the right file name and it does exist?
Help
what is the error message? or what does it output?
I have it to where that it checks if the file opens correctly by using the fail() method. It says couts fail and then asks you to move on.
whenever some thing fails while reading a file the error flag is set to true, after that all subsequent read will fail. so when you find some error while reading and come over it reset the error flag to false before you proceed.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// 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;
}
Topic archived. No new replies allowed.