标签:c
实例3:读写字节文件,每次读入一个缓存里面。
#include<stdio.h>
#include <stdlib.h>
#define MAXLEN 1024
int main()
{
FILE *fpin ;
FILE *fpout;
unsigned char buf[MAXLEN];
int c;
fpout=fopen("c:\\dest.jpg","wb");
if((fpin=fopen("c:\\test.jpg","rb"))!=NULL)
{
c = fread(buf,sizeof(unsigned char),MAXLEN,fpin);
while(c!=0)
{
fwrite(buf,sizeof(unsigned char),c,fpout);
c=fread(buf,sizeof(unsigned char),MAXLEN,fpin);
}
}
else
{
printf("file not exist!");
exit(1);
}
fclose(fpin);
fclose(fpout);
return 0;
}
标签:c
原文地址:http://simoniu.blog.51cto.com/2566344/1409141