Monday, November 21

Read a file and copy content to other file~ C code




This C program will read an input file and copy the content to another file with Line numbers..!!


#include<stdio.h>
main()
{
      FILE *f1,*f2;
      int t=0;
      char line[20];
      f1=fopen("in.c","r");
      f2=fopen("out.c","w");
   
      while(!feof(f1)){
      fgets(line,20,f1);
      t++;
      fprintf(f2,"%d  %s",t,line);
      }
     getch();
      }

0 comments :

Post a Comment