Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main (int argc, char **argv)
- {
- FILE *file_in, *file_out;
- char buff[300];
- int len;
- if (argc > 2)
- {
- if ((file_in = fopen(argv[1], "r")) != NULL)
- if ((file_out = fopen(argv[2], "w")) != NULL)
- {
- while (!feof(file_in))
- {
- if (fgets(buff, 228, file_in))
- {
- len = strlen(buff);
- if (buff[len - 2] == argv[3][0])
- {
- printf("%s", buff);
- fprintf(file_out, "%s", buff);
- }
- }
- }
- fclose(file_in);
- fclose(file_out);
- }
- else
- puts("file could not be created!");
- else
- puts("file could not be opened!");
- }
- else
- puts("too few arguments!\nUsage:\nfindstr.exe [source file] [destination file] [last symbol in string]");
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment