首页 > 其他 > 详细

C 语言文件拷贝

时间:2014-08-09 18:09:58      阅读:269      评论:0      收藏:0      [点我收藏+]

 

相关的方法:

int fputs(const char*s,FILE *stream);

int gets(char *s,int size,FILE *stream);

 

具体代码如下

 

/**
*@author cody
*@date 2014-08-09
*@description copy text file
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char const *argv[])
{
    
    FILE *in = fopen("copy.c","r");
    FILE *out = fopen("copy_1.c","w+");
    if(in == NULL || out == NULL){
        perror("open file error");
        exit(0);
    }

    int size = 20;
    char buf[20];
    while(fgets(buf,20,in) != NULL){
        fputs(buf,out);
    }

    fclose(in);
    fclose(out);


    return 0;
}

 

C 语言文件拷贝,布布扣,bubuko.com

C 语言文件拷贝

原文:http://www.cnblogs.com/cody1988/p/3901147.html

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