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 }  
  • 相关阅读:
    os 模块1
    除法
    python基础四(jsonossys andomstring模块、文件、函数)
    python基础三(集合、文件)
    linux下mysql安装
    linux下tomcat安装
    linux系统jdk安装
    python基础二(list,tuple元祖、dic字典,字符串)
    python基础一(安装、变量、循环、git)
    charles抓包
  • 原文地址:https://www.cnblogs.com/guochaoxxl/p/14054198.html
Copyright © 2011-2022 走看看