Advertisement
pauloludewig

esesrioso 2

Aug 1st, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.94 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. int main()
  5. {
  6.     char nomearquivo[22], atual;
  7.     FILE *arquivo1, *arquivo2, *arquivo3;
  8.  
  9.     printf("digite o nome do primeiro arquivo a ser lido:");
  10.     fflush(stdin);
  11.     gets(nomearquivo);
  12.     strcat(nomearquivo, ".txt");
  13.     arquivo1 = fopen(nomearquivo, "r");
  14.  
  15.     printf("digite o nome do segundo arquivo a ser lido:");
  16.     fflush(stdin);
  17.     gets(nomearquivo);
  18.     strcat(nomearquivo, ".txt");
  19.     arquivo2 = fopen(nomearquivo, "r");
  20.  
  21.     arquivo3 = fopen("saida.txt", "w");
  22.  
  23.     do
  24.     {
  25.         atual = fgetc(arquivo1);
  26.         if (atual != EOF)
  27.         fputc(atual, arquivo3);
  28.     }   while (atual != EOF);
  29.  
  30.     do
  31.     {
  32.         atual = fgetc(arquivo2);
  33.         if (atual != EOF)
  34.         fputc(atual, arquivo3);
  35.     }   while (atual != EOF);
  36.  
  37.     fclose(arquivo1);
  38.     fclose(arquivo2);
  39.     fclose(arquivo3);
  40.  
  41.     system("saida.txt");
  42.  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement