Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main(int argc, char *argv[])
- {
- FILE *fp_in;
- FILE *fp_out;
- // Zad.2
- if (argc != 4)
- {
- printf("nieprawidlowa liczba parametrow\n");
- exit(1);
- }
- char *input_file = argv[1];
- char *output_file = argv[2];
- char *mode = argv[3];
- // Zad.3
- if ((fp_in = fopen(input_file, "rb")) == NULL)
- {
- printf("Nie udalo sie otworzyc pliku wjesciowego\n");
- exit(1);
- };
- if ((fp_out = fopen(output_file, "wb")) == NULL)
- {
- printf("Nie udalo sie otworzyc pliku wyjsciowego\n");
- exit(1);
- };
- // Zad.4
- fseek(fp_in, 0, SEEK_END);
- int size_in = ftell(fp_in);
- fseek(fp_in, 0, 0);
- char *buffor = malloc((size_in)+1);
- fread(buffor, 1, size_in, fp_in);
- buffor[(size_in)] = 0;
- if (strcmp(mode, "-copy")==0)
- {
- copy(buffor, fp_out, size_in);
- }
- else
- {
- if (strcmp(mode,"-replace") == 0)
- {
- replace(buffor, fp_out, size_in);
- }
- }
- fclose(fp_in);
- fclose(fp_out);
- free(buffor);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement