printHumanReadSize(output, splitgroesse);
}
-int cmpfunc(const void * filea,
- const void * fileb) {
- long long unsigned int a = ((const struct file_size*)filea)->fsize;
- long long unsigned int b = ((const struct file_size*)fileb)->fsize;
+int cmpfunc(const void *filea,
+ const void *fileb) {
+ long long unsigned int a = ((const struct file_size*) filea)->fsize;
+ long long unsigned int b = ((const struct file_size*) fileb)->fsize;
if (a < b) {
return 1;
- } else if(a > b) {
+ } else if (a > b) {
return -1;
- } else if(a == b) {
+ } else if (a == b) {
return 0;
} else {
return -2;
fseek(in, 0L, SEEK_SET);
// struct Array with Dateienanzahl
- struct file_size fs[lines -1];
+ struct file_size *fs = NULL;
+ fs = (struct file_size *) malloc((lines -1) * sizeof(struct file_size));
lines = 0;
while (fscanf(in, "%[^\n]\n", pfad) == 1) {
}
}
+ fs = (struct file_size *) realloc(fs, (lines+1) * sizeof(struct file_size));
+
// sortiere das array fs mit stucts
qsort(fs, lines, sizeof(struct file_size), cmpfunc);