LFIND - linear search.
(Compatible with UNIX System V C) 
Usage:
#include <stdio.h>
#include <search.h>
char *lfind();
ptr = lfind( key, table, tsize_p, keysize, compar);
Where:
    - char *key; 
 
    - points to the key you are searching for. This can
        actually be any type of information, but the pointer must
        be cast into (char *). 
 
    - char *table; 
 
    - points to the beginning of a table that contains
        information to search. This need not be sorted in any
        order. 
 
    - unsigned int *tsize_p; 
 
    - points to an unsigned integer that gives the number of
        elements in the table. 
 
    - int keysize; 
 
    - is equal to "sizeof(*key)", i.e. the size (in
        bytes) of the key you are searching for. 
 
    - int (*compar)(char *,char *); 
 
    - is a pointer to a user-defined function that determines
        whether or not two keys are equal. This function should
        take two (char *) arguments; one will point to the key
        you are looking for and the other will point to a key in
        the table. The function should return a zero if the two
        keys are equal, and a non-zero value otherwise. 
 
    - char *ptr; 
 
    - points to a table element that matches "key".
        If no match was found, this will be the NULL pointer. 
 
Description:
"lfind" performs a linear search through the
elements of a table. It uses the user-supplied "compar"
function to compare elements in the table. If the desired key is
not found in the table, a NULL pointer is returned. 
Note that "compar" does not have to do a
byte-by-byte comparison between the key and the table elements.
For example, the table may be an array of C structures and
"compar" may only look at a particular field when
comparing two structures. In this case, the original search key
might just be a dummy, with only the significant field filled in.
See Also:
    - expl c lib lsearch 
 
    - linear search with table update 
 
    - expl c lib bsearch 
 
    - binary search 
 
    - expl c lib hsearch 
 
    - hash functions 
 
    - expl c lib tsearch 
 
    - tree search 
 
Copyright © 1996, Thinkage Ltd.