Re: qsort Confusion Programming Software Development by Ancient Dragon >>qsort(array[c], length, sizeof(int), compare); that is incorrect. You … array of char pointers not an array of integers [icode]qsort(array, c, sizeof(char*), compare);[/icode] Your compare function is… qsort Programming Software Development by Ancient Dragon …strings such as [icode]char array[255][20][/icode] qsort works ok as expected. But if I declare the …array like this qsort fails: [icode]char*array[255][/icode] [code] // this… NumStrings = 0; // fill in the array is not shown here qsort(array, NumStrings, sizeof(array[0]), compare); [/code] or [code]… Re: qsort Programming Software Development by Beair.GQ // fill in the array is not shown here qsort(array, NumStrings, sizeof(array[0]), compare); here,"sizeof(array[0])" is 20bytes; // fill in the array is not shown here qsort(array, NumStrings, sizeof(array[0]), compare); but here,"sizeof(arry[0])" arry[0] is a pointer,so it's mean 4bytes Re: qsort Programming Software Development by Ancient Dragon … ","good"}; c = sizeof(_array)/sizeof(_array[0]); qsort(_array,c, sizeof(char*),compare); cout << "\n… Qsort Programming Software Development by patsfan4878 … to complete the bubblesort portion of the book but the Qsort is still giving me a bit of an issue. Basically… Re: Qsort Programming Software Development by patsfan4878 … to complete the bubblesort portion of the book but the Qsort is still giving me a bit of an issue. Basically… Re: Qsort Programming Software Development by Aia … done anything to it. You are asking for help about Qsort. Please, post any tries that you have done by yourself… qsort on array of pointer to structure Programming Software Development by logicalguy …value called id. I want to use qsort to sort this array of pointers to … { *(mboo+i) = &master[i]; } printf("\nbefore qsort\n"); for (i = 0; i < count; i++)…(**(mboo+i)).id, (**(mboo+i)).size); } qsort(mboo, count, sizeof(struct mys*), indirectstructsortbyid); printf("\nafter… Re: qsort on array of pointer to structure Programming Software Development by Adak … of them need casting like the qsort() version. I'd like to see some qsort examples that eliminate casting to and… from the call to qsort, and it's compare function. When you want to sort… you do is cast the string array to type void *: qsort((void *) strArray, . . . Then the compare function has to cast … Re: qsort on array of pointer to structure Programming Software Development by Dave Sinkula …[QUOTE=Adak;1148021]I'd like to see some qsort examples that eliminate casting to and from the call …to qsort, and it's compare function.[/quote] Sure: [CODE]#…:"); show(data, addr, count); [COLOR="Red"]qsort(addr, count, sizeof *addr, indirec_by_id); [/COLOR] puts("… qsort structs' strings (C) Programming Software Development by chester1908 … const int myCompare (const void *a, const void *b) ; void qsort(void *base, size_t count, size_t size, int (*comp)(const void… ->\n"); size_t structs_len = sizeof(catalogue) / sizeof(struct catPage); qsort (catalogue,structs_len,sizeof(struct catPage),myCompare); for (i=0;i… qsort Confusion Programming Software Development by picklesandmayo … sort multiple words alphabetically using [TEX]qsort ()[/TEX]. I have been using examples of [TEX]qsort ()[/TEX] found on the web and…;< endl; array[c] = token; token = strtok(NULL,delim); c++; } qsort(array[c], length, sizeof(int), compare); cout << "… qsort question Programming Software Development by lehe Hi, I am sorting an double array, using qsort() #include<stdio.h> #include<stdlib.h&…>= * (double** ) arg2 ); } .... int main(int argc,char *argv[]){ ... qsort(array, size_ct,sizeof(double),compar); ... } It turns out that the…you point out why it is wrong? And is qsort() in C standard library and available in both Windows … Re: qsort on array of pointer to structure Programming Software Development by Adak … the compare function, is one reason I dislike C's qsort. Sure, it's nice for different kinds of data, but… Re: qsort on array of pointer to structure Programming Software Development by Dave Sinkula … the compare function, is one reason I dislike C's qsort. Sure, it's nice for different kinds of data, but… Re: qsort structs' strings (C) Programming Software Development by nezachem … fills up the global one; which one is passed to qsort, I have no idea. Verify it with the debugger. On… whole array. On another side note, why are you redeclaring qsort? It is already declared in stdlib.h. Re: qsort structs' strings (C) Programming Software Development by chester1908 hey nez.Thanks for fast reply.Although you are right,no line 28 doesn't cause the problem. But you may be right. If the qsort function could not be executed for some reason (eg wrong comp function) i would get compiler error.But i dont get any so qsort must be used on some other (?) array..Any suggestions? Re: qsort Confusion Programming Software Development by picklesandmayo …;< endl; array[c] = token; token = strtok(NULL,delim); c++; } qsort(array, c, sizeof(char*), compare); cout << "\n… qsort() function help Programming Software Development by coderoobie :'( Hi geeks!, since I started programming I have never used qsort() for sorting. I also tried to consult books but, 'little or no success!'. Can anyone who know better help me to understand qsort() function. Please do it with an example! Happy forever even faced with c++! Re: qsort question Programming Software Development by ArkM …, it's incorrect result because your compar is wrong. Read qsort specification carefully. That's a quote from the C language… qsort with array of structures in c giving a segmentation fault Programming Software Development by benclifford …order. I am hoping I can do this using the qsort function but this is giving a segmentation fault. I …; } addSmurfToVillage(&num_elements, &temp_array, village); num_elements++; } close(fp); qsort(village, num_elements, sizeof(SMURF), cmpr); batchCount(&num_elements, village, &… Qsort with structs using double as the pivot Programming Software Development by Kirielson Hello everyone, I'm trying to implement qsort on a struct with the double as a pivot: typedef … -1; if (x > y) return 1; else return 0; } ... qsort(x,k,sizeof(tuple),compare); Now I was trying to… Re: qsort() function help Programming Software Development by jencas Take a look at [url]http://www.cplusplus.com/reference/clibrary/cstdlib/qsort.html[/url] Re: qsort() function help Programming Software Development by coderoobie [QUOTE=jencas;675529]Take a look at [url]http://www.cplusplus.com/reference/clibrary/cstdlib/qsort.html[/url][/QUOTE] Wot a quick reply! Thanks jencas I 'l have a look at it. One more question, Can I sort a listbox containing strings? :icon_cool: Re: Qsort with structs using double as the pivot Programming Software Development by tinstaafl …[i].prob << ","; cout << endl; qsort(testarray,3,sizeof(test),compare); for(int i=0;i… Qsort Pointer To Arrays Of Structs Programming Software Development by stolson …); 97 } 98 void sort(ADDRESS *a, int *i) 99 { 100 qsort(a, *i, sizeof(ADDRESS),compare); 101 } 102 103 104 int… Re: Qsort Pointer To Arrays Of Structs Programming Software Development by stolson … zip; } ADDRESS; and then: void sort(ADDRESS *a, int *i) { qsort(a, *i, sizeof(struct pb_s),compare); } int compare(const void… Qsort an array of structures by 2 criteria Programming Software Development by The 42nd … array} print_struct_array(structs, structs_len); puts("*** Struct sorting (name)..."); qsort(structs, structs_len, sizeof(struct record), function_comparing_names); print_struct_array(structs, structs_len); } int… Re: Qsort an array of structures by 2 criteria Programming Software Development by Narue …;, 3}, {"C", 1} }; int size = 6; int i; qsort(records, size, sizeof(*records), compare); for (i = 0; i <… qsort() in struct Programming Software Development by VergilDevil123 …. resztvevo adatai: ", i); olvas(&t); tomb[i]=t; } qsort(tomb, n, sizeof (tomb[0]), sort_age); for (i=1;i…