Program to copy any file using FILE method


#include<stdio.h>
main()
{
      char in_name[25],out_name[25];
      FILE *in, *out;
      char c;
      printf("Enter name of file to copy :");
      scanf("%s",in_name);
      printf("\nEnter name to copy it :");
      scanf("%s",out_name);
      if((in=fopen(in_name,"r"))==(FILE*)NULL)
      printf("Could not open %s for reading.\n",in_name);
      else if ((out=fopen(out_name,"w"))==(FILE*)NULL)
      printf("\nCould not open %s for writing.\n",out_name);
      else
      {
          while((c=getc(in))!=EOF)
          putc(c,out);
          printf("\nFile has been created.\n");
      }
      getch();
}

Comments

Popular posts from this blog

Migrating database from ASP.NET Identity to ASP.NET Core Identity

Customize User's Profile in ASP.NET Identity System

Lambda two tables and three tables inner join code samples