#include<stdio.h>
#include<math.h>
#include<dos.h>
#include <dir.h>
#include<graphics.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
void main()
{
char s[]="sub_1.bmp";
struct ffblk C_ffblk;
char C_path[30],D_path[20];
FILE *C_fp,*D_fp;
strcpy(C_path, "C:\\TURBOC2\\");
strcat(C_path,s); /*复制要拷贝的路径和文件名*/
strcpy(D_path, "h:\\" );
strcat(D_path,s); printf("C=%s,D=%s",C_path,D_path);
if((C_fp=fopen(C_path,"r"))==NULL) printf("can't open this source file"); /*源文件只读*/
if((D_fp=fopen(D_path,"w"))==NULL) printf("can't open this objective file"); /*目标文件可写*/
datacopy(C_fp,D_fp);
fclose(C_fp); fclose(D_fp);
}
/**************************** 文件拷贝****************************************/
datacopy(FILE *rbfp,FILE *wbfp) /**rbfp=read file wbfp=write file **/
{ int ch1;
ch1 = fgetc(rbfp);
while(ch1!=EOF)
{ fputc(ch1,wbfp); ch1 = fgetc(rbfp); fputc(ch1,wbfp); }
}
大家帮我看看,这个复制文件的程序为什么不行呀,和实际原来的文件大小不一样呀?如何动态的复制文件