.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" References consulted: .\" Linux libc source code .\" 386BSD man pages .\" Modified Sat Jul 24 18:50:48 1993 by Rik Faith (faith@cs.unc.edu) .\" Interchanged `needle' and `haystack'; added history, aeb, 980113. .\" Translated into Spanish Wed Mar 4 10:07:39 CET 1998 by Gerardo .\" Aburruzaga García .\" Translation revised Wed Aug 19 1998 by Juan Piernas .\" .TH MEMMEM 3 "13 Enero 1998" "GNU" "Manual del Programador de Linux" .SH NOMBRE memmem \- localiza una subcadena .SH SINOPSIS .nf .B #define _GNU_SOURCE .br .B #include .sp .BI "void *memmem(const void *" haystack ", size_t " haystacklen , .in +\w'void *memmem('u .BI "const void *" needle ", size_t " needlelen ); .in .fi .SH DESCRIPCIÓN La función \fBmemmem()\fP busca el principio de la primera ocurrencia de la subcadena \fIneedle\fP de longitud \fIneedlelen\fP en el área de memoria \fIhaystack\fP de longitud \fIhaystacklen\fP. .SH "VALOR DEVUELTO" La función \fBmemmem()\fP devuelve un puntero al principio de la subcadena, o NULL si la subcadena no se encuentra. .SH "CONFORME A" Esta función es una extensión GNU. .SH FALLOS Esta función se adaptó a las bibliotecas de Linux y se incluyó a partir de la versión 5.0.9 de libc; allí los argumentos `needle' y `haystack' estaban intercambiados y se devolvía un puntero al final de la primera ocurrencia de \fIneedle\fP. Ya que todavía se usa ampliamente libc 5.0.9, es peligroso utilizar esta función. .br Tanto la antigua como la nueva libc tienen el fallo de que si \fIneedle\fP es vacío, se devuelve \fIhaystack\fP-1 (en lugar de \fIhaystack\fP). Y glibc 2.0 lo hace peor todavía y devuelve un puntero al último byte de `haystack'. Ésto ha sido solucionado en glibc 2.1. .SH "VÉASE TAMBIÉN" .BR strstr (3)