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, * g;
- char str[255];
- f = fopen("textfile", "w");
- puts("Enter strings:");
- while (gets_s(str), strcmp(str, ""))
- {
- fputs(str, f);
- fputs("\n", f);
- }
- fclose(f);
- f = fopen("textfile", "r");
- puts("File:");
- while (fgets(str, 255, f) != NULL)
- printf("%s", str);
- fclose(f);
- f = fopen("textfile", "r");
- g = fopen("tmp", "w");
- while (fgets(str, 255, f) != NULL)
- if (strlen(str) >= 6)
- fputs(str, g);
- fclose(f);
- fclose(g);
- remove("textfile");
- rename("tmp", "textfile");
- g = fopen("textfile", "r");
- puts("\nFile:");
- while (fgets(str, 255, g) != NULL)
- printf("%s", str);
- fclose(g);
- return 0;
- }
Add Comment
Please, Sign In to add comment