回复 10楼 炎天
这样也可以~ /*while(!feof(in))
{
len++;
ch = fgetc(in);
}*/
fseek(in,0L,2);
len=ftell(in);
fseek(in, 0L,0);
[code]/*~个性签名:bug是什么意思?bug是看上去没有可能的东西实际上是有可能做到的 就是这样~2018-08-08更~*/[/code]
#include<stdio.h> #include<windows.h> #include<stdlib.h> main() { char start[100]; int len = 0 ,t = 0 ,l = 0; FILE *in,*out; char ch,infile[10],outfile[10]; printf("enter the name of the fileread:"); scanf("%s",infile); printf("enter the name of the filewrite:"); scanf("%s",outfile); if((in=fopen(infile,"r"))==NULL) { printf("can not open the file!\n"); exit(0); } if((out=fopen(outfile,"w"))==NULL) { printf("can not open the file!\n"); exit(0); } fseek(in,0L,2); len=ftell(in); fseek(in, 0L,0); while(!feof(in)) { t++; ch=fgetc(in); fputc(ch,out); start[t-1] = ch; printf("%*.*s",-(len+1),t,start); printf("\t\t"); printf("%.2lf", 1.0*(t-1)/len); Sleep(280); for(l = 0; l <+12+len+1+3; l++) { printf("\b"); } } putchar(10); fclose(in); fclose(out); }
#include <stdio.h> #include <string.h> #include <windows.h> int main(void) { FILE *in,*out; char ch; in=fopen("1.txt","rb"); out=fopen("2.txt","w"); fseek(in,0,SEEK_END); int fsize=ftell(in); char* t="Now it will copping completed: "; int len=(int)strlen(t); fseek(in,0,SEEK_SET); ch=fgetc(in); int i=1; while(!feof(in)) { fputc(ch,out); printf("%s %6.2lf",t,1.0*i/fsize*100); Sleep(30); for(int k=0;k<len+7;k++) printf("\b"); ch=fgetc(in); i++; } printf("\n"); fclose(in); fclose(out); return 0; }