Advertisement
RiQ363

9lab

Jan 5th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.05 KB | None | 0 0
  1. //---------------------------------------------------------------------------
  2.  
  3. #pragma hdrstop
  4.  
  5. //---------------------------------------------------------------------------
  6.  
  7. #pragma argsused
  8.  
  9. #include <conio.h>
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12.  
  13. int ReadnPrint (char *filename1, char *filename2, char *filename3)
  14. {
  15.  FILE *f,*g,*h;
  16.  char line1[500], line2[500], line3[500]; char c;
  17.   if((f=fopen(filename1,"rt"))==NULL)
  18.    printf("File could not be opened\n");
  19.   if((g=fopen(filename2,"rt"))==NULL)
  20.    printf("File could not be opened\n");
  21.   if((h=fopen(filename3,"wt"))==NULL)
  22.    printf("File could not be opened\n");
  23.   while (fgets(line1,500,f)!=NULL && fgets(line2,500,g)!=NULL)
  24.   {
  25.     fputs(line1,h);
  26.    if(strcmp(line2, line1)!=0)
  27.     fputs(line2,h);
  28.   }
  29.   fclose(f);
  30.   fclose(g);
  31.   fclose(h);
  32.   return 0;
  33. }
  34.  
  35. int main ()
  36. {
  37.  char *filename1="F:\\1.txt";
  38.  char *filename2="F:\\2.txt";
  39.  char *filename3="F:\\3.txt";
  40.  ReadnPrint ("F:\\1.txt","F:\\2.txt","F:\\3.txt");
  41.  printf("Operation Complete.");
  42.  getchar();
  43.  return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement