Minor fixes

This commit is contained in:
Michael Kerrisk 2007-06-07 09:15:29 +00:00
parent 616a81401d
commit 668fdda191
1 changed files with 8 additions and 8 deletions

View File

@ -25,7 +25,7 @@
.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
.\" 386BSD man pages
.\" Modified Sat Jul 24 18:11:47 1993 by Rik Faith (faith@cs.unc.edu)
.\" 2007-06-15, Marc Boyer <marc.boyer@enseeiht.fr>
.\" 2007-06-15, Marc Boyer <marc.boyer@enseeiht.fr> + mtk
.\" Improve discussion of strncat().
.TH STRCAT 3 2007-06-15 "GNU" "Linux Programmer's Manual"
.SH NAME
@ -42,8 +42,8 @@ strcat, strncat \- concatenate two strings
The
.BR strcat ()
function appends the \fIsrc\fP string to the
\fIdest\fP string, overwriting the null character (`\\0') at the end of
\fIdest\fP, and then adds a terminating null character.
\fIdest\fP string, overwriting the null byte ('\\0') at the end of
\fIdest\fP, and then adds a terminating null byte.
The strings may not overlap, and the \fIdest\fP string must have
enough space for the result.
.PP
@ -63,12 +63,12 @@ the resulting string in \fIdest\fP is always null terminated.
If \fIsrc\fP contains \fIn\fP or more characters,
.BR strcat ()
writes \fIn+1\fP characters to \fIdest\fP (\fIn\fP
from \fIsrc\fP plus the terminating null character).
Therefore, the size of \fIdest\fP must be at least
from \fIsrc\fP plus the terminating null byte).
Therefore, the size of \fIdest\fP must be at least
\fIstrlen(dest)+n+1\fP.
A simple implementation of
.BR strncat ()
.BR strncat ()
might be:
.in +0.25i
.nf
@ -79,9 +79,9 @@ strncat(char *dest, const char *src, size_t n)
size_t dest_len = strlen(dest);
int i;
for(i = 0 ; i < n && src[i] != '\0' ; i++)
for(i = 0 ; i < n && src[i] != '\\0' ; i++)
dest[dest_len + i] = src[i];
dest[dest_len + i] = '\0';
dest[dest_len + i] = '\\0';
return dest;
}