zoukankan      html  css  js  c++  java
  • 文件的复制贴贴

    #include "stdafx.h"
    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
        FILE *readfile,*writefile;
        char ch;
        fopen_s(&readfile,"ReadMe.txt","r");
         fopen_s(&writefile,"abc.txt","w");
        if(readfile == NULL)
        {
            printf_s("读文件打开失败");
            getchar();
            exit(1);
        }
        if(writefile == NULL)
        {
            printf_s("文件打开失败");
            getchar();
            exit(1);
        }
        while((ch = fgetc(readfile)) != EOF)
        {
            printf_s("get a word");
            fputc(ch,writefile);
        }
        int id1 = fclose(readfile);
        int id2 = fclose(writefile);
        system("pause");
        if(id1 != 0)
        {
            printf_s("文件关闭失败");
        }
        else
        {
            printf_s("文件关闭成功");
        }
        if(id2 != 0)
        {
            printf_s("文件关闭失败");
        }
        else
        {
            printf_s("文件关闭成功");
        }
        system("pause");
        return 0;
    }


    ReadMe.txt 与 abc.txt stdafx.cpp stdafx.h 放在一起
  • 相关阅读:
    lnmp分离部署
    Nginx
    Keepalived脑裂监控
    KVM虚拟化
    mysql中间件proxysql实现mysql读写分离
    分离部署lnmp
    nginx
    Keepalived脑裂监控
    keepalived高可用
    KVM虚拟化
  • 原文地址:https://www.cnblogs.com/joyclub/p/4434893.html
Copyright © 2011-2022 走看看