qc.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
lfind, lsearch
 Summary Example                         Up Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
     The lsearch and lfind functions perform a linear search for the
     value <key> in an array of <num> elements, each <width> bytes in
     size. (Unlike bsearch, lsearch and lfind do not require the array
     to be sorted.) The <base> argument is a pointer to the base of the
     array to be searched.
 
     If <key> is not found, lsearch adds it to the end of the array,
     and lfind returns NULL.
 
     The <compare> argument is a pointer to a user-supplied routine
     that compares the key with an array element and returns a value
     specifying their relationship. Both lsearch and lfind call the
     <compare> routine one or more times during the search, passing
     pointers to the key and an array element on each call. The
     routine must compare the two, then return one of the following
     values:
 
     Value       Meaning
 
     Nonzero     <key> and <elem> are different
 
     0           <key> is identical to <elem>
 
     Return Value
 
     If the key is found, both lsearch and lfind return a pointer to
     the array element <base> that matches <key>. If the key is not
     found, lfind returns NULL and lsearch returns a pointer to a newly
     added item at the end of the array.
                                    -♦-