• 数据文件——之复制二进制文件


    代码:

     1 //This is c program code!
     2 /* *=+=+=+=+* *** *=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
     3   * 文档信息: *** :~/WORKM/stutyCode/cCode/recipesProblemSolution/chapter06/test6_18.c
     4   * 版权声明: *** :(魎魍魅魑)MIT
     5   * 联络信箱: *** :guochaoxxl@163.com
     6   * 创建时间: *** :2020年11月22日的上午10:33
     7   * 文档用途: *** :数据结构与算法分析-c语言描述
     8   * 作者信息: *** :guochaoxxl(http://cnblogs.com/guochaoxxl)
     9   * 修订时间: *** :2020年第46周 11月22日 星期日 上午10:33 (第327天)
    10   * 文件描述: *** :自行添加
    11  * *+=+=+=+=* *** *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+*/
    12 #include <stdio.h>
    13 
    14 void resultOpen(FILE *fPtr){
    15     if(fPtr == NULL){
    16         printf("File opening failed.
    ");
    17         return;
    18     }
    19     printf("File opening successfully.
    ");
    20 
    21     return;
    22 }
    23 
    24 void closeState(FILE *fPtr){
    25     int clo = fclose(fPtr);
    26     if(clo == -1){
    27         puts("file-closing failed.");
    28     }
    29     if(clo == 0){
    30         puts("file-closing successfully.");
    31     }
    32 }
    33 
    34 int main(int argc, char **argv)
    35 {
    36     FILE *fPtrSource = fopen("hello", "rb");
    37     resultOpen(fPtrSource);                                                             
    38     
    39     FILE *fPtrTarget = fopen("hellor", "wb");
    40     resultOpen(fPtrTarget);
    41 
    42     int ch = fgetc(fPtrSource);
    43     while(ch != EOF){
    44         fputc(ch, fPtrTarget);
    45         ch = fgetc(fPtrSource);
    46     }
    47     puts("");
    48     puts("File copied successfully.
    ");
    49 
    50     closeState(fPtrSource);
    51     closeState(fPtrTarget);
    52 
    53     return 0;
    54 }
  • 相关阅读:
    数据转换类型和算数运算符
    语言基础+数据类型
    JS(一)Prototype的使用
    Jquery EasyUI简介和数据的增删改查
    http简介
    《JavaScript语言精粹》笔记
    wcf
    简单工厂模式与抽象工厂模式
    <转载>C#中的特性(Attributes)
    <转载>C#IEnumerable和IEnumerator 详解
  • 原文地址:https://www.cnblogs.com/guochaoxxl/p/14054224.html
Copyright © 2020-2023  润新知