From: SF/projects/mingw n. l. <min...@li...> - 2011-12-03 17:33:29
|
Bugs item #3448694, was opened at 2011-12-02 16:13 Message generated for change (Comment added) made by earnie You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=3448694&group_id=2435 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: MinGW Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Rene de Zwart (renez52) Assigned to: Nobody/Anonymous (nobody) Summary: qsort problem Initial Comment: if I compile thsi simple program ------------------------------------------------------------------------------ #include <stdio.h> int sortint(const void *a, const void *b){ return *(int *) a < *(int *) b; } int rene[] ={ 10,1,100,3,2,99,4,999,102 }; int main(){ int i; for(i =0; i <sizeof(rene)/sizeof(int);i++) printf("%d) %d\n",i,rene[i]); qsort(rene,sizeof(rene)/sizeof(int), sizeof(int), sortint); printf("sorted is\n\n"); for(i =0; i <sizeof(rene)/sizeof(int);i++) printf("%d) %d\n",i,rene[i]); } ------------------------------------------------------------------------------------------------ i get 0) 10 1) 1 2) 100 3) 3 4) 2 5) 99 6) 4 7) 999 8) 102 sorted is 0) 102 1) 999 2) 100 3) 99 4) 10 5) 4 6) 3 7) 2 8) 1 which is obvious wrong. Compiling the same program under linux gives 0) 10 1) 1 2) 100 3) 3 4) 2 5) 99 6) 4 7) 999 8) 102 sorted is 0) 999 1) 102 2) 100 3) 99 4) 10 5) 4 6) 3 7) 2 8) 1 ---------------------------------------------------------------------- >Comment By: Earnie Boyd (earnie) Date: 2011-12-03 09:33 Message: I do too, I even corrected your programming bug* and still do not get the expected result. However, there is nothing we (MinGW) can do about the issue since MicroSoft is its producer**. I found an example*** which works with your array but I cannot get your program to work. *) You need to #include <stdlib.h> **) http://msdn.microsoft.com/en-us/library/zes7xw0h.aspx ***) http://www.cpp-tips.net/QSort ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=3448694&group_id=2435 |