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

    代码:

     1 //This is c program code!                                                               
     2 /* *=+=+=+=+* *** *=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
     3   * 文档信息: *** :~/WORKM/stutyCode/cCode/recipesProblemSolution/chapter06/test7_13.c
     4   * 版权声明: *** :(魎魍魅魑)MIT
     5   * 联络信箱: *** :guochaoxxl@163.com
     6   * 创建时间: *** :2020年11月21日的下午06:48
     7   * 文档用途: *** :数据结构与算法分析-c语言描述
     8   * 作者信息: *** :guochaoxxl(http://cnblogs.com/guochaoxxl)
     9   * 修订时间: *** :2020年第46周 11月21日 星期六 下午06:48 (第326天)
    10   * 文件描述: *** :自行添加
    11  * *+=+=+=+=* *** *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+*/
    12 #include <stdio.h>
    13 #include "closeState.h"
    14 
    15 #define SIZE 10
    16     
    17 int main(int argc, char **argv)
    18 {   
    19     int arrNum[SIZE];
    20     FILE *fPtr = fopen("num.dat", "rb");
    21     if(fPtr != NULL){
    22         puts("File num.dat is opened successfully.");
    23         fread(arrNum, sizeof(int), SIZE, fPtr);
    24         puts("Contents of file num.dat: ");
    25     
    26         for(int i = 0; i < 10; i++){
    27             printf("%d	", arrNum[i]);
    28         }
    29         printf("
    ");
    30     
    31         int clo;
    32         closeState(clo, fPtr);
    33     }else{
    34         puts("File-opening failed!");
    35     }
    36     
    37     return 0;
    38 }
  • 相关阅读:
    java框架--Spring XML 配置基础(一)
    工具的使用与安装--oracle卸载
    java web--jsp(4)
    java web--JSP(3)
    洛谷 P3384 【模板】轻重链剖分
    洛谷 P1103 书本整理
    洛谷 P1977 出租车拼车
    洛谷 P1129 [ZJOI2007]矩阵游戏
    洛谷 P2319 [HNOI2006]超级英雄
    洛谷 P1640 [SCOI2010]连续攻击游戏
  • 原文地址:https://www.cnblogs.com/guochaoxxl/p/14054194.html
Copyright © 2011-2022 走看看