Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <locale.h>
- #include <windows.h>
- #include <conio.h>
- #include <stdlib.h>
- #define _CRT_SECURE_NO_WARNINGS
- int main()
- {
- int k = 0;
- FILE* F;
- char str[100];
- char FILEName1[20];
- char FILEName2[20];
- puts("Enter first file name");
- gets_s(FILEName1, 20);
- fopen_s(&F, FILEName1, "w+b");
- puts("Enter strings");
- while (gets_s(str, 100), strlen(str) != 0)
- {
- fwrite(&str, 1, sizeof(str), F);
- }
- rewind(F);
- puts("FileF");
- while (fread(&str, 1, sizeof(str), F) > 0)
- puts(str);
- rewind(F);
- FILE* G;
- puts("Enter second file name");
- gets_s(FILEName2, 20);
- fopen_s(&G, FILEName2, "w+b");
- while (fread(&str, 1, sizeof(str), F) > 0)
- {
- if (k % 2 == 0)
- {
- fwrite(&str, 1, sizeof(str), G);
- }
- k++;
- }
- fclose(F); fclose(G);
- puts("Elements of file G");
- fopen_s(&G, FILEName2, "r+b");
- int num = 1;
- while (fread(&str, 1, sizeof(str), G) > 0)
- {
- printf_s("string order %d ", num);
- puts(str);
- num += 2;
- }
- fclose(G);
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement