Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main()
- {
- char nomearquivo[22], atual;
- FILE *arquivo1, *arquivo2, *arquivo3;
- printf("digite o nome do primeiro arquivo a ser lido:");
- fflush(stdin);
- gets(nomearquivo);
- strcat(nomearquivo, ".txt");
- arquivo1 = fopen(nomearquivo, "r");
- printf("digite o nome do segundo arquivo a ser lido:");
- fflush(stdin);
- gets(nomearquivo);
- strcat(nomearquivo, ".txt");
- arquivo2 = fopen(nomearquivo, "r");
- arquivo3 = fopen("saida.txt", "w");
- do
- {
- atual = fgetc(arquivo1);
- if (atual != EOF)
- fputc(atual, arquivo3);
- } while (atual != EOF);
- do
- {
- atual = fgetc(arquivo2);
- if (atual != EOF)
- fputc(atual, arquivo3);
- } while (atual != EOF);
- fclose(arquivo1);
- fclose(arquivo2);
- fclose(arquivo3);
- system("saida.txt");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement