Implementing copy command using file my code is copying garbage.please help me to fix
#include<stdio.h>
int main()
{
char ch;
FILE *fp,*fp1;
fp=fopen("source","r");
if(fp==NULL)
{
printf("no file\n");
return;
}
else
{
printf("file is present\n");
fp1=fopen("dest","w");
while(ch=fgetc(fp)!=EOF)
fputc(ch,fp1); // why source contain is not copyed to dest?
}
fclose(fp);
fclose(fp1);
}