码迷,mamicode.com
首页 > 编程语言 > 详细

将结构体数组中内容以文件形式的导出

时间:2018-11-26 00:09:01      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:nta   out   output   email   txt   put   ESS   数组   成功   

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;
}

将结构体数组中内容以文件形式的导出

标签:nta   out   output   email   txt   put   ESS   数组   成功   

原文地址:https://www.cnblogs.com/likeghee/p/10017555.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!