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+t");
- puts("Enter strings");
- int b = 0;
- 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+t");
- fseek(F, 0, SEEK_SET);
- fgets(str, 100, F);
- b = atoi(str);
- fseek(F, 0, SEEK_END);
- fgets(str, 100, F);
- b += atoi(str);
- sprintf_s(str, "%d", b);
- fputs(str, G);
- fclose(F); fclose(G);
- puts("Elements of file G");
- fopen_s(&G, FILEName2, "r+t");
- int num = 1;
- while (fgets(str, 100, G) > 0)
- {
- printf_s("string order %d ", num);
- puts(str);
- }
- fclose(G);
- return(0);
- }
Add Comment
Please, Sign In to add comment