利用fopen创建a.txt和b.txt。利用fwrite向a.txt写入“hello world”,接着将a.txt的“hello world”读到缓冲区,再将缓冲区的“hello world”写入到b.txt。
#include
#include
#include
#include
#include
#include
#include
int main()
{
char *buf="Hello World";
char buffer[11];
int len;
FILE *in, *out;
len = strlen(buf);
in = fopen("readfile","r+b");
out = fopen("writefile","r+b");
fwrite(buf,len+1,1,in);
fseek(in,0,SEEK_SET);
while(fread(buffer,len+1,1,in) == 1)
fwrite(buffer,len+1,1,out);
fclose(out);
fclose(in);
exit(0);
}
阅读(2384) | 评论(0) | 转发(0) |