evgenko

Lab_for_sasha_13

May 6th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.11 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.     FILE *afile = NULL;
  5.     FILE *bfile = NULL;
  6.     FILE *cfile = NULL;
  7.     cfile = fopen("C", "w");
  8.     if (cfile == NULL) {
  9.         puts("Error create file C");
  10.         return 0;
  11.     }
  12.     afile = fopen("A", "r");
  13.     if (afile ==NULL){
  14.         puts("Error open file A");
  15.         return 0;
  16.     }
  17.     char symbol;
  18.     while(fread(&symbol,sizeof(char), 1, afile)== sizeof(char)){
  19.         if (symbol == '>' || symbol == '=' || symbol == '<'){
  20.             fwrite(&symbol,sizeof(char), 1, cfile);
  21.         }
  22.     }
  23.     fclose(cfile);
  24.     fclose(afile);
  25.     bfile = fopen("B", "r");
  26.     if (bfile == NULL) {
  27.         puts("Error create file C");
  28.         return 0;
  29.     }
  30.     afile = fopen("A", "a");
  31.     if (afile ==NULL){
  32.         puts("Error open file A");
  33.         return 0;
  34.     }
  35.     while(fread(&symbol,sizeof(char), 1, bfile)== sizeof(char)){
  36.         if ((symbol >='a' && symbol <= 'z') || (symbol >= 'A' && symbol <= 'Z')){
  37.             fwrite(&symbol,sizeof(char), 1, afile);
  38.         }
  39.     }
  40.     fclose(bfile);
  41.     fclose(afile);
  42.     fclose(cfile);
  43.     return 0;
  44. }
Add Comment
Please, Sign In to add comment