you mean the function qsort() in crt? here is a sample struct foostruct{ int key; int value1; int value2; };
int compare(const void* a1, const void* a2){ return ((foostruct*)a1)->key - ((const foostruct*)a2)->key; } void bar(){ foostruct s[] ={ {3, 2, 3}, {5, 2, 1}, {2, 6, 5} }; qsort(s, sizeof(s)/sizeof(s[0]), sizeof(s[0]), compare); } Thank U! On Tue, Dec 7, 2010 at 3:30 AM, ANUJ KUMAR <kumar.anuj...@gmail.com> wrote: > how can i use qsort a structure. > please give me the code if possibe > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.