zoukankan      html  css  js  c++  java
  • 数据文件——之将整数写入文本文件

    代码:

     1 //This is c program code!
     2 /* *=+=+=+=+* *** *=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
     3   * 文档信息: *** :~/WORKM/stutyCode/cCode/recipesProblemSolution/chapter06/test6_7.c
     4   * 版权声明: *** :(魎魍魅魑)MIT
     5   * 联络信箱: *** :guochaoxxl@163.com
     6   * 创建时间: *** :2020年11月21日的上午08:20
     7   * 文档用途: *** :数据结构与算法分析-c语言描述
     8   * 作者信息: *** :guochaoxxl(http://cnblogs.com/guochaoxxl)
     9   * 修订时间: *** :2020年第46周 11月21日 星期六 上午08:20 (第326天)
    10   * 文件描述: *** :自行添加
    11  * *+=+=+=+=* *** *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+*/
    12 #include <stdio.h>
    13 
    14 int main(int argc, char **argv)
    15 {
    16     FILE *fPtr = fopen("numbers.dat", "w");
    17     if(fPtr != NULL){
    18         puts("File numbers.dat is opened successfully.");
    19         for(int i = 0; i < 10; i++){
    20             fprintf(fPtr, "%d", i + 1);
    21         }
    22         puts("Data written to file numbers.dat successfully.");
    23         
    24         int clo = fclose(fPtr);
    25         if(clo == -1){
    26             puts("File-closing failed!");
    27         }
    28         if(clo == 0){
    29             puts("File is closed successfully.");
    30         }   
    31     }else{  
    32         puts("File-opening failed!");                                                   
    33     }       
    34         
    35     return 0;
    36 }
  • 相关阅读:
    5,7地面物品
    0,1选怪
    0,2使用红,蓝
    BT地址(__)
    3,7包裹物品数组
    0,4捡物
    如何在目标内网中发现更多存活主机
    xss自动化攻击
    .NET Framework 4安装失败
    利用struts1.x框架需要注意的问题
  • 原文地址:https://www.cnblogs.com/guochaoxxl/p/14054153.html
Copyright © 2011-2022 走看看