Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int concat(char* input_path1, char* input_path2, char* output_path)
- {
- FILE *input_file1;
- FILE *input_file2;
- FILE *output_file;
- int c;
- output_file = fopen(output_path, "w");
- input_file1 = fopen(input_path1, "r+");
- while((c = fgetc(input_file1)) != EOF)
- {
- printf("%c", (char)c);
- fprintf(output_file, "%c", (char)c);
- }
- fclose(input_file1);
- input_file2 = fopen(input_path2, "r+");
- while((c = fgetc(input_file2)) != EOF)
- {
- printf("%c", (char)c);
- fprintf(output_file, "%c", (char)c);
- }
- fclose(input_file2);
- fclose(output_file);
- }
- char* lirechar()
- {
- int n=0;
- char *c=(char*)malloc(1);
- char saisie=getchar();
- while(saisie!='\n')
- {
- c[n]=saisie;
- saisie=getchar();
- n++;
- c=(char*)realloc(c,n+1);
- }
- c[n]='\0';
- return c;
- }
- int main()
- {
- char* input_path1;//={'1','.','t','x','t'};
- char* input_path2;//={'2','.','t','x','t'};
- char* output_path;//={'3','.','t','x','t'};
- input_path1=lirechar();
- input_path2=lirechar();
- output_path=lirechar();
- concat(input_path1, input_path2, output_path);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement