首页 > 其他 > 详细

文件的复制贴贴

时间:2015-04-17 15:25:58      阅读:140      评论:0      收藏:0      [点我收藏+]
#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 放在一起

 

文件的复制贴贴

原文:http://www.cnblogs.com/joyclub/p/4434893.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!