Advertisement
Guest User

Untitled

a guest
May 28th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1. #include <stdio.h>
  2.  int main(){
  3.    char a[1000];
  4.    char file1[100],file2[100],file3[100];
  5.    
  6.     printf("\nИмя файла N1: ");
  7.     scanf("%s", file1);
  8.     printf("\nИмя файла N2: ");
  9.     scanf("%s", file2);
  10.     printf("\nИмя файла N3: ");
  11.     scanf("%s", file3);
  12.  
  13.     FILE *f1 = fopen(file1, "r");
  14.     FILE *f2 = fopen(file2, "r");
  15.     FILE *f3 = fopen(file3, "w");
  16.    
  17.         if (f1 == NULL || f2 == NULL || f3 == NULL){
  18.             printf("Невозможно открыть файл");
  19.             return 1; }
  20.         else{
  21.             while (!feof(f1) || !feof(f2))
  22.         {       if(!feof(f1))
  23.             {       fscanf(f1,"%s",a);
  24.                     fprintf(f3,"%s\n",a); }
  25.                 if(!feof(f2))
  26.             {       fscanf(f2,"%s",a);
  27.                     fprintf(f3,"%s\n",a);}
  28.         }
  29.      }
  30.     fclose(f1);
  31.     fclose(f2);
  32.     fclose(f3);
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement