房天下 > 房天下问答 > 业主生活 > 其他
  • vc++ 高手请进!!在线等...

    #include<iostream>#include<fstream>#include<string>using namespace std;struct student{ int num; string name; float score;};int main(){ student stud[5]; stud[0].num=1001;stud[0].name="Li";stud[0].score=85; stud[1].num=1002;stud[1].name="Fun";stud[1].score=97.5; stud[2].num=1004;stud[2].name="Wang";stud[2].score=54; stud[3].num=1006;stud[3].name="Tan";stud[3].score=76.5; stud[4].num=1010;stud[4].name="Ling";stud[4].score=96; fstream iofiles("c:\\stud.dat",ios::in|ios::out|ios::binary); if(!iofiles) { cout<<"open stud.dat error!"<<endl; exit(1); } return 0;}

    提问者:zdz8904

    发布于2011-01-25

共1个回答
  • ljundong 丨Lv 4
    如果只要输出的话,把fstream iofiles("c:\\stud.dat",ios::in|ios::out|ios::binary);中的ios::in给去掉,否则如果stud.dat文件不存在就会出现无法打开的情况
    +1 2011-01-25 举报
热门人气推荐
免责声明:问答内容均来源于互联网用户,房天下对其内容不负责任,如有版权或其他问题可以联系房天下进行删除。