第9单元io流类库与异常处理2(免费阅读).pptVIP

  • 3
  • 0
  • 约2.05万字
  • 约 55页
  • 2017-01-02 发布于重庆
  • 举报

第9单元io流类库与异常处理2(免费阅读).ppt

9.4.3  二进制文件的读写 void inventory::Bdatafromfile(ifstreamsour){ char k[20]; sour.read(k,20);//提取20个字符到k中 Description=k; sour.read(k,10); //提取10个字符到k中 No=k; sour.read((char*)Quantity,sizeof(int));//取地址强制转换 sour.read((char *)Cost,sizeof(double)); sour.read((char *)Retail,sizeof(double)); } //参见写过程,读写完全对称,次序决不能错 9.4.3  二进制文件的读写 void inventory::Bdatatofile(ofstreamdist){ dist.write(Description.c_str(),20); dist.write(No.c_str(),10); dist.write((char*)Quantity,sizeof(int)); dist.write((char*)Cost,sizeof(double)); d

文档评论(0)

1亿VIP精品文档

相关文档