zoukankan      html  css  js  c++  java
  • 数据文件——之读取写入二进制文件的结构

    代码:

     1 //This is c program code!
     2 /* *=+=+=+=+* *** *=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
     3   * 文档信息: *** :~/WORKM/stutyCode/cCode/recipesProblemSolution/chapter06/test6_14.c
     4   * 版权声明: *** :(魎魍魅魑)MIT
     5   * 联络信箱: *** :guochaoxxl@163.com
     6   * 创建时间: *** :2020年11月21日的下午07:17
     7   * 文档用途: *** :数据结构与算法分析-c语言描述
     8   * 作者信息: *** :guochaoxxl(http://cnblogs.com/guochaoxxl)
     9   * 修订时间: *** :2020年第46周 11月21日 星期六 下午07:17 (第326天)
    10   * 文件描述: *** :自行添加
    11  * *+=+=+=+=* *** *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+*/
    12 #include <stdio.h>
    13 #include "closeState.h"
    14 
    15 int main(int argc, char **argv)
    16 {
    17     Bio bio; 
    18     FILE *fPtr = fopen("agentsb.dat", "rb");
    19     if(fPtr != NULL){
    20         printf("File agentsb.dat is opened successfully.
    ");
    21         int ch = fread(&bio, sizeof(bio), 1, fPtr);
    22         while(ch != 0){
    23             printf("Name: %s, RollNo: %d, Age: %d, Weight: %.1f
    ", bio.name, bio.rollNo   , bio.age, bio.weight);
    24             ch = fread(&bio, sizeof(bio), 1, fPtr);
    25         }
    26         int clo;
    27         closeState(clo, fPtr);
    28     }else{
    29         puts("File-opening failed.");
    30     }   
    31         
    32     return 0;                                                                           
    33 }  
  • 相关阅读:
    团队项目 NABCD介绍
    java web项目通过外网ip访问
    第七周总结
    全球疫情可视化展示
    第六周总结
    软工小队——团队介绍
    Android端疫情数据统计与现实——Android连接Mysql
    android SDK SDK Manager.exe 无法打开,一闪而过最终解决办法 (转)
    第五周总结
    Java代码编写规范(转)
  • 原文地址:https://www.cnblogs.com/guochaoxxl/p/14054198.html
Copyright © 2011-2022 走看看