Joe Tyman
Joe Tyman

Reputation: 1417

No matching function for call to "qsort"

I can't seem to get qsort to work in my problem. I look around online and my code should be correct.

int file::compare (const void * a, const void * b)
{
     fileinfo* fa = (fileinfo*)a;
     fileinfo* fb = (fileinfo*)b;
     return (*(int*)fa->inode - *(int*)fb->inode);
}

void file::print()
{
    qsort((void *)files, 100, sizeof(fileinfo), compare);
}

files is an array of fileinfo. struct fileinfo is a struct that contains the name and inode of a file.

Upvotes: 1

Views: 1348

Answers (1)

Mark Ransom
Mark Ransom

Reputation: 308216

file::compare must be declared static to be used as a parameter to qsort.

Upvotes: 7

Related Questions