Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define BUFF_SIZE 4096
- int main(int argc, char **argv)
- {
- if (argc != 4)
- {
- fprintf(stderr, "usage: %s source_file1 source_file2 destenation_file3\n", argv[0]);
- return 1;
- }
- FILE *fsrc1, *fsrc2, *fdst3;
- if ((fsrc1 = fopen(argv[1], "rb")) == NULL)
- {
- perror("error source_file1");
- return 2;
- }
- if ((fsrc2 = fopen(argv[2], "rb")) == NULL)
- {
- perror("error source_file2");
- fclose(fsrc1);
- return 3;
- }
- if ((fdst3 = fopen(argv[3], "wb")) == NULL)
- {
- fclose(fsrc1);
- fclose(fsrc2);
- perror("error destenation_file3");
- return 4;
- }
- size_t byte_read = 0;
- char buff[BUFF_SIZE];
- while ((byte_read = fread(buff, sizeof(char), BUFF_SIZE, fsrc1)))
- fwrite(buff, sizeof(char), byte_read, fdst3);
- while ((byte_read = fread(buff, sizeof(char), BUFF_SIZE, fsrc2)))
- fwrite(buff, sizeof(char), byte_read, fdst3);
- fclose(fsrc1);
- fclose(fsrc2);
- fclose(fdst3);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment