请各位前辈指点下,本人自学的C没人教,先谢了.
本人想把一个文件中的数字复制到另一个文件中,运行时一闪而过,但是文件也复制成功.为什么不显示结果.请专业的你修正下.#include <stdio.h>
#define N 1000
mycopy(); /* mycopy的原形说明*/
myout(int a[],int i); /*myout的原开说明*/
main()
{int a=0,i=0;
FILE *Fp=NULL;
mycopy(); /*调用cycopy*/
getch();
Fp=fopen("d:\\tan\\1.txt","r");
if(Fp==NULL)
{printf("can not open the file.\n");
exit(0);
}
while(feof(Fp)==0)
{fsanf(Fp,"%d",&a);
printf("%-3d",a);
i++;
if(i%10==0)
printf("\n");
}
sytem("pause");
fclose(Fp);
}
mycopy()
{int arry[N],i=0,b=0;
FILE *Fp=NULL;
Fp=fopen("d:\\tan\\0.txt","r");
if(Fp==NULL)
{printf("can not open the file.\n");
exit(0);
}
while(feof(Fp)==0)
{fscanf(Fp,"%d",&b);
arry[i]=b;
i++;
}
fclose(Fp);
myout(arry,i); /*调用myout*/
}
myout(int a[],int i)
{int k=0;
FILE *Fp=NULL;
Fp=fopen("d:\\tan\\1.txt","w");
if(Fp==NULL)
{printf("can not open the file.\n");
exit(0);
}
for(k=0;k<i;k++)
fprintf(Fp,"%3d",a[k]);
fclose(Fp);
}