zoukankan      html  css  js  c++  java
  • 数据文件——之逐个字符串读取文本文件

    代码:

     1 //This is c program code!
     2 /* *=+=+=+=+* *** *=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
     3   * 文档信息: *** :~/WORKM/stutyCode/cCode/recipesProblemSolution/chapter06/test6_5.c
     4   * 版权声明: *** :(魎魍魅魑)MIT
     5   * 联络信箱: *** :guochaoxxl@163.com
     6   * 创建时间: *** :2020年11月20日的下午09:49
     7   * 文档用途: *** :数据结构与算法分析-c语言描述
     8   * 作者信息: *** :guochaoxxl(http://cnblogs.com/guochaoxxl)
     9   * 修订时间: *** :2020年第46周 11月20日 星期五 下午09:49 (第325天)
    10   * 文件描述: *** :自行添加
    11  * *+=+=+=+=* *** *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+*/
    12 #include <stdio.h>
    13 
    14 int main(int argc, char **argv)
    15 {
    16     char *cPtr;
    17     char store[80];
    18     FILE *fPtr = fopen("kolkata.txt", "r");
    19     if(fPtr != NULL){
    20         puts("File kolkata.txt is opened successfully!");                               
    21         puts("Contents of this file: ");
    22         cPtr = fgets(store, 80, fPtr);
    23 
    24         while(cPtr != NULL){
    25             printf("%s", store);
    26             cPtr = fgets(store, 80, fPtr);
    27         }
    28 
    29         int k = fclose(fPtr);
    30         if(k == -1){
    31             puts("File-closing failed!");
    32         }
    33         if(k == 0){
    34             puts("
    File is closed successfully.");
    35         }
    36     }else{
    37         puts("File-opening failed!");
    38     }
    39 
    40     return 0;
    41 }
  • 相关阅读:
    CSS3——过渡
    CSS——优雅降级和渐进增强
    jq1 颜色填充器 和清空指定颜色
    1. 初识node
    javaSE- 01
    鼠标悬浮图片时弹出透明提示图层的jQuery特效
    通过jQuery制作电子时钟表的代码
    9种网页Flash焦点图和jQuery焦点图幻灯片
    7种网页图片切换方式代码
    21种网页在线客服代码实例演示
  • 原文地址:https://www.cnblogs.com/guochaoxxl/p/14054143.html
Copyright © 2011-2022 走看看