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

Pages: 1-

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 6:14

No SEH

Name: Anonymous 2008-03-10 6:20

is this your own implementation of these functions?

Name: Anonymous 2008-03-10 6:27

>>2
SEH Exception Handler.

Name: Anonymous 2008-03-10 7:20

>>1
gdb

Name: Anonymous 2008-03-10 8:16

i see another argument you fucking faggort.

Name: Anonymous 2008-03-10 8:27

>>6
shaddap idort

Name: Anonymous 2008-03-10 8:45

Why doesn't MSVC++EE support C nowadays?

Name: Anonymous 2008-03-10 8:48

MSVC
MSVC
MSVC
MSVC

Name: Anonymous 2008-03-10 10:16

>>9
MSVC Visual Sepples.

Name: Anonymous 2008-03-10 10:25

Microsoft Visual Haskell.net
http://www.haskell.org/visualhaskell/

Name: Anonymous 2008-03-10 11:44

>>11
Is it written in Perl 6?

Name: Anonymous 2008-03-10 11:49

C SUCKS

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.

Name: Anonymous 2008-03-10 12:14

>>14
Because bsearch needs to manipulate the pointer.
If you'd look at the prototype of bsearch it's probably something like
bsearch(char **, ..)
You passed a char* where char** was expected.
Oh, and don't try char **word; bsearch(word, ..) it will not work.
In short, learn C and read the god damn documentation (if any) of the functions you are using.

Name: Anonymous 2008-03-10 12:29

>>12
Perl 6 is written in Haskell.
Haskell is written in Visual Haskell.
Visual Haskell is written in Perl 6.

Name: Anonymous 2008-03-10 12:46

>>16
EXPERT OUROBORIC RECURSION

Name: Anonymous 2008-03-10 17:37

>>17
This may surprise you, but I invented the recursive ouroborossnake.

Name: Anonymous 2008-03-10 23:26

>>18
The ouroboros snake is recursive by definition.

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