m0_64509442 2022-05-14 01:53 采纳率: 83.3%
浏览 22
已结题

c加加 学生代码 小错误

#include
using namespace std;
struct student
{char name[20];
int num;
int age;
char sex;
};
int main()
{student stud[3]={"Li",1001,18,'f',"Fang",1002,19,'m',"Wang",1004,17,'f'};
ofstream outfile("stud.dat",ios::binary);
if(!outfile)
{cerr<<"open error!"<<endl;
abort();

}
for(int i=0;i<3;i++)
outfile.write((char*)&stud[i],sizeof(stud[i]));
outfile,close();
return 0;
}

img

  • 写回答

1条回答 默认 最新

  • 树下等苹果 2022-05-14 02:10
    关注

    outfile.close();的‘.’你写成逗号了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

问题事件

  • 系统已结题 5月26日
  • 已采纳回答 5月19日
  • 创建了问题 5月14日