#include <sys/stat.h>
#include <unistd.h>
+void filecopy(const char *fsource, const char *ftarget)
+{
+ FILE *source; FILE *target;
+ char ch;
+
+ source = fopen(fsource, "r");
+ target = fopen(ftarget, "w");
+
+ while((ch = fgetc(source)) != EOF)
+ fputc(ch, target);
+
+ fclose(source);
+ fclose(target);
+}
+
int exists(const char *fname)
{
struct stat buffer;
const char *input = argv[1];
const char *output = argv[2];
const char *rest = argv[3];
+ const char *work = "work";
unsigned long long split;
int c;
extern char *optarg;
}
}
- splitter(input, output, rest, split);
+ filecopy(input, work);
+ splitter(work, output, rest, split);
+ remove(work);
return 0;
}