Mail Archives: djgpp/1999/06/08/13:39:35
In article <002301beb1c6$025023c0$4d806ec3 AT marte> you wrote:
> I think I found a bug in the qsort() function.
No, the bug is in your program, at least as of the program you
posted. You lie about the result of the compare function ('0' means
"equal"), so what makes you think that qsort() will be able to find
out the result that you think should be correct? Mind-reading?
More seriously: qsort is explicitly not guaranteed to not change the
order of already sorted entries in the array, or of entries which
compare as 'zero', as returned by the comparison functon. To quote
from the C Standard, where it defines what qsort() does:
If two elements compare as equal, their order in the sorted
array is unspecified.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -