HP C/iX Library Reference Manual (30026-90004)
Chapter 5 239
HP C/iX Library Function Descriptions
lsearch
pointer-to-element.
Undefined results can occur if there is not enough room in the table to add a new item.
Example
This fragment reads in TABSIZE strings of length ELSIZE and stores them in a table,
eliminating duplicates.
#include stdio.h>
#include search.h>
#define TABSIZE 50
#define ELSIZE 120
char line[ELSIZE], tab[TABSIZE][ELSIZE], *lsearch( );
unsigned nel = 0;
int strcmp( );
…
while (fgets(line, ELSIZE, stdin) != NULL
nel TABSIZE)
(void) lsearch(line, (char *)tab,nel,
ELSIZE, strcmp);
…
See Also
lfind()