Generic Sort
- From: "AB" <abjbhat@xxxxxxxxx>
- Date: 24 May 2006 03:58:33 -0700
Hello All,
I'm trying to replicate a general purpose sort function (think qsort)
void sort(void *arr, const int num, size_t size,
int (*cmp)(void *a, void *b))
{
int i = 0 ;
int j = 0 ;
for (i = (num - 1) ; i >= 0 ; i--)
{
for (j = 1 ; j <= i ; j++)
{
if(cmp((int *) &arr[j-1], (int *) &arr[j])) //Error
{
//swapping logic
}
}
}
}
MSVC 8 (2005) reports 2 errors when trying to call cmp:-
error C2036: 'void *' : unknown size
error C2036: 'void *' : unknown size
I've tried a few variations, but I can't seem to get it right. Can
anybody help?
Thanks in advance.
.
- Follow-Ups:
- Re: Generic Sort
- From: Tomás
- Re: Generic Sort
- From: pete
- Re: Generic Sort
- From: sandy
- Re: Generic Sort
- From: Richard Heathfield
- Re: Generic Sort
- Prev by Date: Re: why can't we use static type as structure member?
- Next by Date: Re: exact time
- Previous by thread: What this mean? Compiler output
- Next by thread: Re: Generic Sort
- Index(es):
Relevant Pages
|