file won't open

What is wrong with this code? I'm trying to create a binary file and then write to it, but my file validation keeps alerting me that the file didn't open successfully.

 
  char filename[]= "employees.dat";


1
2
  fstream myFile;
  myFile.open(filename,ios::in | ios::out | ios::binary);
Try without ios::in. I don't think fstream will create the file if it doesn't exist with that flag.
yes that worked! i thought since fstream is for both read and write that I had to include both. Thanks Peter87!
Topic archived. No new replies allowed.