.\" Copyright (C) 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 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" Modified Sat Jul 24 18:06:49 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified Fri Aug 25 23:17:51 1995 by Andries Brouwer (aeb@cwi.nl) .\" Modified Wed Dec 18 00:47:18 1996 by Andries Brouwer (aeb@cwi.nl) .\" .\" Translated into Spanish Wed Mar 11 09:51:23 CET 1998 by Gerardo .\" Aburruzaga García .\" .TH STRCPY 3 "11 abril 1993" "GNU" "Manual del Programador de Linux" .SH NOMBRE strcpy, strncpy \- copian una cadena de caracteres .SH SINOPSIS .nf .B #include .sp .BI "char *strcpy(char *" dest ", const char *" orig ); .sp .BI "char *strncpy(char *" dest ", const char *" orig ", size_t " n ); .fi .SH DESCRIPCIÓN La función \fBstrcpy()\fP copia la cadena de caracteres apuntada por \fIorig\fP (incluyendo el carácter terminador '\\0') al vector apuntado por \fIdest\fP. Las cadenas no deben solaparse, y la de destino, \fIdest\fP, debe ser suficientemente grande como para alojar la copia. .PP La función \fBstrncpy()\fP es similar, pero no se copiarán más de \fIn\fP bytes de \fIorig\fP. Así, si el byte cero no está entre los primeros \fIn\fP bytes de \fIorig\fP, el resultado no será una cadena terminada en cero. .PP En el caso en que la longitud de .I orig sea menor que la de .IR n , el resto de .I dest se rellenará con ceros. .SH "VALOR DEVUELTO" Las funciones \fBstrcpy()\fP y \fBstrncpy()\fP devuelven un puntero a la cadena destino \fIdest\fP. .SH FALLOS Si la cadena destino de un \fBstrcpy()\fP no es bastante grande (esto es, si el programador fue estúpido o perezoso, y no comprobó el tamaño antes de la copia) entonces puede ocurrir cualquier cosa. Provocar el desbordamiento de cadenas de caracteres de longitud fija es una técnica favorita de los piratas informáticos. .SH "CONFORMES CON" SVID 3, POSIX, BSD 4.3, ISO 9899 .SH "VÉASE TAMBIÉN" .BR bcopy "(3), " memccpy "(3), " memcpy "(3), " memmove (3)