Search This Blog

Translate

write c file handling program to copy file using using CMD

 write c file handling program to copy file using using CMD

#include
#include
#include
void main(int argc,char *argv[])
{
  FILE *source,*dest;
  int ch;
  clrscr();
  if(argc!=3)
  {
   printf("\n Wrong no of argument");
   exit(1);
  }
  source=fopen(argv[1],"r");
  if(source==NULL)
  {
   printf("\n Source file not found");
   exit(1);
  }
  dest=fopen(argv[2],"a");
  if(dest==NULL)
  {
   printf("\n destination file not found");
   exit(1);
  }
  while((ch=fgetc(source))!=EOF)
    fputc(ch,dest);
  printf("\n File copied");
  fclose(source);
  fclose(dest);
 getch();
}




C Program example List

Google+ Badge