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