Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C

Name: Anonymous 2008-03-10 5:54

Why does qsort work while bsearch causes a segmentation fault when they both have the same arguments?

char *word
...
qsort(dictionary, dictionarySize, sizeof(char *), dict_compare);

bsearch(word, dictionary, dictionarySize, sizeof(char *), dict_compare);

It works if I replace bsearch with manually stepping through the array. Any ideas?

Name: Anonymous 2008-03-10 11:52

OP here

Turns out I had to use
bsearch(&word, dictionary, dictionarySize, sizeof(char *), dict_compare);

I don't even know why. In every example I've seen they didn't need to do that. What the fuck.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List