求cb中filewrite函数的用法???
展开全部
#include<iostream>
#include<fstream>
using namespace std;
struct student
{
char name;
int num;
int age;
char sex;
};
int main()
{student stud[3]={"li",1001,14,'f',"Fun",1002,19,'m',"wang",1003,21,'f'};
ofstream outfile("d:\\stud.txt",ios::binary);
if(!outfile)
{
ceer<<"open error!"<<endl;
abort();
}
for(int i=0;i<3;i++)
outfile.write((char *)&stud[i],sizeof(stud[i]));
outfile.close();
return 0;
}
#include<fstream>
using namespace std;
struct student
{
char name;
int num;
int age;
char sex;
};
int main()
{student stud[3]={"li",1001,14,'f',"Fun",1002,19,'m',"wang",1003,21,'f'};
ofstream outfile("d:\\stud.txt",ios::binary);
if(!outfile)
{
ceer<<"open error!"<<endl;
abort();
}
for(int i=0;i<3;i++)
outfile.write((char *)&stud[i],sizeof(stud[i]));
outfile.close();
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询