Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <conio.h>
- #include <stdlib.h>
- 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)
- {
- fputs(str,F);
- fputs("\n", F);
- }
- rewind(F);
- puts("FileF");
- while (fgets(str, 100, F) > 0)
- {
- puts(str);
- }
- rewind(F);
- FILE* G;
- puts("Enter second file name");
- gets_s(FILEName2, 20);
- fopen_s(&G, FILEName2, "w+b");
- while (fgets(str, 100, F) > 0)
- {
- if (k % 2 == 0)
- {
- fputs(str, G);
- }
- k++;
- }
- fclose(F); fclose(G);
- puts("Elements of file G");
- fopen_s(&G, FILEName2, "r+b");
- int num = 1;
- while (fgets(str, 100, 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