Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <string.h>
- int main()
- {
- FILE* f;
- char str[255];
- f = fopen("BINARY.bin", "wb");
- puts("Enter the sequence:");
- gets_s(str);
- fwrite(str, sizeof(str), 1, f);
- fclose(f);
- f = fopen("BINARY.bin", "rb");
- fread(str, sizeof(str), 1, f);
- puts("File:");
- puts(str);
- fclose(f);
- char new_str[255];
- int cnt = 0;
- for (int i = 0; i < strlen(str); i++)
- {
- if ((int(str[i]) - 48) % 5 != 0)
- {
- new_str[cnt] = str[i];
- cnt++;
- }
- }
- new_str[cnt] = '\0';
- f = fopen("BINARY.bin", "wb");
- fwrite(new_str, sizeof(str), 1, f);
- fclose(f);
- f = fopen("BINARY.bin", "rb");
- fread(str, sizeof(str), 1, f);
- puts("Changed file:");
- puts(str);
- fclose(f);
- return 0;
- }
Add Comment
Please, Sign In to add comment