Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- char a[1000];
- char file1[100],file2[100],file3[100];
- printf("\nИмя файла N1: ");
- scanf("%s", file1);
- printf("\nИмя файла N2: ");
- scanf("%s", file2);
- printf("\nИмя файла N3: ");
- scanf("%s", file3);
- FILE *f1 = fopen(file1, "r");
- FILE *f2 = fopen(file2, "r");
- FILE *f3 = fopen(file3, "w");
- if (f1 == NULL || f2 == NULL || f3 == NULL){
- printf("Невозможно открыть файл");
- return 1; }
- else{
- while (!feof(f1) || !feof(f2))
- { if(!feof(f1))
- { fscanf(f1,"%s",a);
- fprintf(f3,"%s\n",a); }
- if(!feof(f2))
- { fscanf(f2,"%s",a);
- fprintf(f3,"%s\n",a);}
- }
- }
- fclose(f1);
- fclose(f2);
- fclose(f3);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement