Skip to content

Instantly share code, notes, and snippets.

@Thibb1
Created January 18, 2022 20:17
Show Gist options
  • Save Thibb1/a3cee275fce07233ca93f92fc5e8c796 to your computer and use it in GitHub Desktop.
Save Thibb1/a3cee275fce07233ca93f92fc5e8c796 to your computer and use it in GitHub Desktop.
Tester for Epitech Cppool d04am
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static void disp(const void *str)
{
printf(" %s", *(char **)str);
}
static int cmp(const void *a, const void *b)
{
return (strcmp(*(char **)a, *(char **)b));
}
int main(int ac, char **av)
{
printf("\nargv:");
disp_array(av, ac, sizeof(*av), &disp);
printf("\nargv no disp:");
disp_array(av, ac, sizeof(*av), NULL);
printf("\nargv no argv:");
disp_array(NULL, ac, sizeof(*av), &disp);
printf("\nuniq:");
ac = uniq_array(av, ac, sizeof(*av), &cmp);
disp_array(av, ac, sizeof(*av), &disp);
printf("\nuniq no cmp:");
disp_array(av, uniq_array(av, ac, sizeof(*av), NULL), sizeof(*av), &disp);
printf("\nuniq no av:");
disp_array(av, uniq_array(NULL, ac, sizeof(*av), &cmp), sizeof(*av), &disp);
printf("\nsort no av:");
sort_array(NULL, ac, sizeof(*av), &cmp);
disp_array(av, ac, sizeof(*av), &disp);
printf("\nsort no cmp:");
sort_array(av, ac, sizeof(*av), NULL);
disp_array(av, ac, sizeof(*av), &disp);
printf("\nsort:");
sort_array(av, ac, sizeof(*av), &cmp);
disp_array(av, ac, sizeof(*av), &disp);
printf("\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment