qsort parameters

Jim Rogers jimr at hplsdv7.COS.HP.COM
Fri May 10 08:03:58 AEST 1991


Since your data structure is char *filename[] you should pass 
sizeof(filename[0]) as the size of your element.  Your strings may differ
in size, but the arrays of characters which hold your strings are all the same
size.  This size is the "element" size required by qsort.

Remember that a string in C is an array of characters with a '\0' somewhere
in that array.  The position of the '\0' determines the length of the string
but not the size of the array.


Jim Rogers
Hewlett-Packard Company
Colorado Springs, Colorado
United States of America



More information about the Comp.unix.questions mailing list