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 放在一起
  • 相关阅读:
    BM&EXCRT
    杨丰磊
    poj3613 Cow Relays
    详解KMP算法
    信息学作文
    恐怖的奴隶主(bob)
    玩具(toy)
    杯子 (glass)
    P3916 图的遍历
    《上帝给我一个任务,叫我牵一只蜗牛去散步》
  • 原文地址:https://www.cnblogs.com/joyclub/p/4434893.html
Copyright © 2011-2022 走看看