标签:des style blog color os io 文件 2014
相关的方法:
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; }
标签:des style blog color os io 文件 2014
原文地址:http://www.cnblogs.com/cody1988/p/3901147.html