Zennoma

Показать это дз

Dec 18th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.09 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <conio.h>
  4. #include <stdlib.h>
  5.  
  6.  
  7.  
  8. int main()
  9. {
  10.     int k = 0;
  11.     FILE* F;
  12.     char str[100];
  13.     char FILEName1[20];
  14.     char FILEName2[20];
  15.     puts("Enter first file name");
  16.     gets_s(FILEName1, 20);
  17.     fopen_s(&F, FILEName1, "w+b");
  18.     puts("Enter strings");
  19.  
  20. while (gets_s(str, 100), strlen(str) != 0)
  21.     {
  22.         fwrite(&str, 1, sizeof(str), F);
  23.     }
  24.     rewind(F);
  25.     puts("FileF");
  26.     while (fread(&str, 1, sizeof(str), F) > 0)
  27.         puts(str);
  28.     rewind(F);
  29.     FILE* G;
  30.     puts("Enter second file name");
  31.     gets_s(FILEName2, 20);
  32.     fopen_s(&G, FILEName2, "w+b");
  33.     int b;
  34.     while (fread(&str, 1, sizeof(str), F) > 0)
  35.     {
  36.         if (b=atoi(str)>0)
  37.         {
  38.             fwrite(&str, 1, sizeof(str), G);
  39.         }
  40.     }
  41.     rewind(F);
  42.     while (fread(&str, 1, sizeof(str), F) > 0)
  43.     {
  44.         if (b = atoi(str) < 0)
  45.         {
  46.             fwrite(&str, 1, sizeof(str), G);
  47.         }
  48.     }
  49.     fclose(F); fclose(G);
  50.     puts("Elements of file G");
  51.     fopen_s(&G, FILEName2, "r+b");
  52.     int num = 1;
  53.     while (fread(&str, 1, sizeof(str), G) > 0)
  54.     {
  55.         printf_s("string order %d  ", num);
  56.         puts(str);
  57.         num++;
  58.     }
  59.     fclose(G);
  60.     return(0);
  61. }
Add Comment
Please, Sign In to add comment