程序没出错,但结果是myfile open error 不知道哪里有问题?

#include
#include
#include
using namespace std;
class Student
{public:
char name[15];
int age;
float height;
Student(char n="0",int a=0,float h=0){strcpy(name,n);age=a;height=h;}
~Student(){}
};
int main()
{Student s[3]={Student("tong",18,165),Student("hei",19,168),Student("xiao",20,170)
},s1;
char filename[]="aaa.dat";
int n=3,i;
fstream myfile;
myfile.open(filename,ios::in|ios::out|ios::binary);
if(!myfile){
cout << "myfile open error" << endl;
abort();
}
for(i=0;i<n;i++){
myfile.write((char
)&s[i],sizeof(class Student));}
myfile.seekp(1sizeof(class Student),ios::beg);
myfile.read((char
)&s1,sizeof(class Student));
myfile.close();
cout << "The name of student is:" <<s1.name<< endl;
cout << "The age of the student is:"<<s1.age << endl;
cout << "The height of the student is:" <<s1.height<< endl;
return 0;
}

if(!myfile){
cout << "myfile open error" << endl;
abort();
}

条件成立就会打印myfile open error;
打印一下myfile看是什么,检测一下文件路径是否正确,或是否有操作权限