zoukankan      html  css  js  c++  java
  • 数据文件——之以以交互模式写入文本文件

    代码:

     1 //This is c program code!
     2 /* *=+=+=+=+* *** *=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
     3   * 文档信息: *** :~/WORKM/stutyCode/cCode/recipesProblemSolution/chapter06/test6_4.c
     4   * 版权声明: *** :(魎魍魅魑)MIT
     5   * 联络信箱: *** :guochaoxxl@163.com
     6   * 创建时间: *** :2020年11月20日的下午07:44
     7   * 文档用途: *** :数据结构与算法分析-c语言描述
     8   * 作者信息: *** :guochaoxxl(http://cnblogs.com/guochaoxxl)
     9   * 修订时间: *** :2020年第46周 11月20日 星期五 下午07:44 (第325天)
    10   * 文件描述: *** :自行添加
    11  * *+=+=+=+=* *** *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+*/
    12 #include <stdio.h>
    13 #include <string.h>
    14 
    15 int main(int argc, char **argv)
    16 {
    17     //char *pathName = (char *)(sizeof(char) * 40);
    18     char pathName[40];
    19     char fileTemp[15];
    20     char fileStore[80];
    21     printf("Enter fileName (AAAAA.aaa) extension optional: ");
    22     scanf("%s", fileTemp);
    23     strcpy(pathName, "~/WORKM");                                                        
    24     strcat(pathName, fileTemp);
    25     FILE *fPtr = fopen(fileTemp, "w");
    26     if(fPtr != NULL){
    27         printf("File %s is opened successfully.
    ", fileTemp);
    28         puts("Ennter the lines of text to sotre in the file.");
    29         puts("Strike Enter key twice to end the line-entry-session.");
    30         fflush(stdin);
    31         gets(fileStore);
    32         int size = strlen(fileStore);
    33 
    34         while(size != 0){
    35             fputs(fileStore, fPtr);
    36             fputs("
    ", fPtr);
    37             gets(fileStore);
    38             size = strlen(fileStore);
    39         }
    40         int clo = fclose(fPtr);
    41         if(clo == -1){
    42             puts("File-closing failed!");
    43         }
    44         if(clo == 0){
    45             puts("File is closed successfully.");
    46         }
    47     }else{
    48         puts("File-opening failed!");
    49     }
    50 
    51     return 0;
    52 }
  • 相关阅读:
    vue动态改变样式
    前端上传到七牛云图片
    vue实现发送验证码60秒
    移动端使用lib-flexible
    作用域插槽
    vue中的keep-alive
    vue优化
    vue动画move的实现
    vue自带的动画效果
    v-model的理解
  • 原文地址:https://www.cnblogs.com/guochaoxxl/p/14054135.html
Copyright © 2011-2022 走看看