
Write gm_qsort, your own qsort, with the signature the C standard gives qsort: order the nmemb elements of size bytes stored at base, comparing any two of them with cmp, and move whole elements byte by byte because size is only known at run time.
int v[] = {4, 1, 7, 3}; gm_qsort(v, 4, sizeof(int), cmp_int_asc);1 3 4 7struct rec v[] = {{30, 3, 300}, {10, 1, 100}, {20, 2, 200}}; gm_qsort(v, 3, sizeof(struct rec), cmp_rec_key); // printed as key:serial:weight10:1:100 20:2:200 30:3:300char v[][3] = {"zz", "ab", "mm"}; gm_qsort(v, 3, 3, cmp_tag_head);ab mm zzchar v[] = {'g', 'a', 'z', 'm'}; gm_qsort(v, 4, sizeof(char), cmp_char_asc); // printed with no separatoragmzstruct rec v[] = {{5, 1, 0}, {5, 2, 0}, {5, 3, 0}}; gm_qsort(v, 3, sizeof(struct rec), cmp_rec_key); // keys, then the serial total5 5 5
sum=6int v[3] = {9, 8, 7}; gm_qsort(v, 0, sizeof(int), cmp_int_asc);9 8 7qsort.c<stddef.h>defines size_tStandard C library
Implements the contract of a function from the standard C library.

Run the tests to grade your code
Write gm_qsort, your own qsort, with the signature the C standard gives qsort: order the nmemb elements of size bytes stored at base, comparing any two of them with cmp, and move whole elements byte by byte because size is only known at run time.
int v[] = {4, 1, 7, 3}; gm_qsort(v, 4, sizeof(int), cmp_int_asc);1 3 4 7struct rec v[] = {{30, 3, 300}, {10, 1, 100}, {20, 2, 200}}; gm_qsort(v, 3, sizeof(struct rec), cmp_rec_key); // printed as key:serial:weight10:1:100 20:2:200 30:3:300char v[][3] = {"zz", "ab", "mm"}; gm_qsort(v, 3, 3, cmp_tag_head);ab mm zzchar v[] = {'g', 'a', 'z', 'm'}; gm_qsort(v, 4, sizeof(char), cmp_char_asc); // printed with no separatoragmzstruct rec v[] = {{5, 1, 0}, {5, 2, 0}, {5, 3, 0}}; gm_qsort(v, 3, sizeof(struct rec), cmp_rec_key); // keys, then the serial total5 5 5
sum=6int v[3] = {9, 8, 7}; gm_qsort(v, 0, sizeof(int), cmp_int_asc);9 8 7qsort.c<stddef.h>defines size_tStandard C library
Implements the contract of a function from the standard C library.

Run the tests to grade your code
Memory will appear here