Hi,
I am trying to make a program which reads 6 integers , insert into a file numbers1.txt
then copy numbers1.txt content to numbers2.txt and finally print numbers2.
The problem I have is that when I am trying to copy the file to another the system crashes.
My code is
#include <stdio.h>
#include <stdlib.h>
int main()
{
int array[6];
int i;
char ch;
FILE *fp1,*fp2;
printf("Give 6 numbers :\n");
for(i=0;i<6;i++)
scanf("%d",&array[i]);
fp1=fopen("numbers1.txt", "wb");
for(i=0; i<6;i++)
fprintf(fp1, "%d\n",array[i]);
fp2=fopen("numbers2.txt","wb");
while(!feof(fp1))
{
ch = fgetc(fp1);
if(!feof(fp1))
fputc(ch, fp2);
}
fclose(fp1);
fclose(fp2);
system("pause");
return 0;
}
Could you help me ?
Thanks a lot