The array you sort contains pointers to process
, so your compare function should look like:
int compar_ppid(const void * v1, const void * v2)
{
process *const*p1 = v1, *const*p2 = v2;
return strcmp((*p1)->ppid, (*p2)->ppid);
}
and as BLUEPIXY points out the allocation of the array is not using the pointer size, but the struct size.