void fileOutput(contacts student[] , int n){
ofstream out ;
out . open("tongxunlu-new.txt") ;
for(int i = 0 ; i<= n-1 ; i++){
out << "学号" << ‘\t‘ <<‘\t‘ << student[i].studentnum << ‘\n‘;
out << "姓名" << ‘\t‘ <<‘\t‘ << student[i].name << ‘\n‘;
out << "性别" << ‘\t‘ <<‘\t‘ << student[i].gender << ‘\n‘;
out << "生日" << ‘\t‘ <<‘\t‘ << student[i].birthday.year <<"年"
<< student[i].birthday.month <<"月"
<< student[i].birthday.day <<"日"
<< ‘\n‘;
out << "家庭住址" << ‘\t‘ <<‘\t‘ << student[i].address << ‘\n‘;
out << "QQ号" << ‘\t‘ <<‘\t‘ << student[i].qqnum << ‘\n‘;
out << "电话号" << ‘\t‘ <<‘\t‘ << student[i].phonenum << ‘\n‘;
out << "email" << ‘\t‘<<‘\t‘<< student[i].email << ‘\n‘<< ‘\n‘;
}
out.close();
cout<<"导出文件成功"<<endl;
}
原文地址:https://www.cnblogs.com/likeghee/p/10017555.html