nikitast

bilet_11

Jan 19th, 2021 (edited)
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5.  
  6. int main()
  7. {
  8.     FILE* f, * g;
  9.     char str[255];
  10.     f = fopen("textfile", "w");
  11.     puts("Enter strings:");
  12.     while (gets_s(str), strcmp(str, ""))
  13.     {
  14.         fputs(str, f);
  15.         fputs("\n", f);
  16.     }
  17.     fclose(f);
  18.     f = fopen("textfile", "r");
  19.     puts("File:");
  20.     while (fgets(str, 255, f) != NULL)
  21.         printf("%s", str);
  22.     fclose(f);
  23.     f = fopen("textfile", "r");
  24.     g = fopen("tmp", "w");
  25.     while (fgets(str, 255, f) != NULL)
  26.         if (strlen(str) >= 6)
  27.             fputs(str, g);
  28.     fclose(f);
  29.     fclose(g);
  30.     remove("textfile");
  31.     rename("tmp", "textfile");
  32.     g = fopen("textfile", "r");
  33.     puts("\nFile:");
  34.     while (fgets(str, 255, g) != NULL)
  35.         printf("%s", str);
  36.     fclose(g);
  37.     return 0;
  38. }
Add Comment
Please, Sign In to add comment