Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main(int argc, char *argv[]){
- char str1[50], str2[50];
- FILE *input1, *input2, *output;
- if (argc != 4){
- printf("Enter 3 file names.\n");
- return 0;
- }
- input1 = fopen(argv[1], "r");
- input2 = fopen(argv[2], "r");
- output = fopen(argv[3], "w");
- if (input1 == NULL || input2 == NULL){
- printf("Error!\n");
- return 0;
- }
- while(!feof(input1) || !feof(input2)){
- if (fgets(str1, 50, input1))
- fprintf(output, "%s", str1);
- if (fgets(str2, 50, input2))
- fprintf(output, "%s", str2);
- }
- printf("Success!\n");
- fclose(input1);
- fclose(input2);
- fclose(output);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement