Scroll to navigation

lsearch(3) Library Functions Manual lsearch(3)

NOMBRE

lfind, lsearch - búsqueda líneal en una matriz

BIBLIOTECA

Biblioteca Estándar C (libc-lc)

SINOPSIS

#include <search.h>
void *lfind(size_t *n, size_t size;
            const void key[size], const void base[*n * size],
            size_t *n, size_t size,
            typeof(int (const void [size], const void [size]))
                *compar);
void *lsearch(size_t *n, size_t size;
            const void key[size], void base[*n * size],
            size_t *n, size_t size,
            typeof(int (const void [size], const void [size]))
                *compar);

DESCRIPCIÓN

lfind() and lsearch() perform a linear search for key in the array base which has *n elements of size bytes each. The comparison function referenced by compar is expected to have two arguments which point to the key object and to an array member, in that order, and which returns zero if the key object matches the array member, and nonzero otherwise.

If lsearch() does not find a matching element, then the key object is inserted at the end of the table, and *n is incremented. In particular, one should know that a matching element exists, or that more room is available.

VALOR DEVUELTO

lfind() devuelve un puntero a un miembro coincidente de la matriz, o NULL si no hubo coincidencias. lsearch() devuelve un puntero a un miembro coincidente de la matriz, o al nuevo miembro añadido si no hubo coincidencias.

ATRIBUTOS

Para obtener una explicación de los términos usados en esta sección, véase attributes(7).

Interfaz Atributo Valor
lfind(), lsearch() Seguridad del hilo Multi-hilo seguro

ESTÁNDARES

POSIX.1-2008.

HISTORIAL

POSIX.1-2001, SVr4, 4.3BSD. libc-4.6.27.

ERRORES

The naming is unfortunate.

VÉASE TAMBIÉN

bsearch(3), hsearch(3), tsearch(3)

TRADUCCIÓN

La traducción al español de esta página del manual fue creada por Vicente Pastor Gómez <vpastorg@santandersupernet.com> y Juan Piernas <piernas@ditec.um.es>

Esta traducción es documentación libre; lea la GNU General Public License Version 3 o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD.

Si encuentra algún error en la traducción de esta página del manual, envíe un correo electrónico a debian-l10n-spanish@lists.debian.org.

28 Junio 2025 Páginas de Manual de Linux (no publicadas)