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 }
  • 相关阅读:
    VBScript 函数
    C#创建activex供js调用
    java调用jni
    vbscript基本语法
    javascript 与vbscript 互相调用
    java调用jni
    mysql 无权限修改user 【修改root密码问题】
    vbscript基本语法
    js九九乘法表
    100~999之间的水仙花数
  • 原文地址:https://www.cnblogs.com/guochaoxxl/p/14054143.html
Copyright © 2011-2022 走看看