*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->OpenBSD man pages -> strncat (3)              
Title
Content
Arch
Section
 

STRCAT(3)

Contents


NAME    [Toc]    [Back]

     strcat, strncat - concatenate strings

SYNOPSIS    [Toc]    [Back]

     #include <string.h>

     char *
     strcat(char *s, const char *append);

     char *
     strncat(char *s, const char *append, size_t count);

DESCRIPTION    [Toc]    [Back]

     The strcat() and strncat() functions append a  copy  of  the
null-terminated
     string  append  to  the end of the null-terminated string s,
then add a terminating
 ` '.  The string s must have  sufficient  space  to
hold the result.


     The  strncat()  function appends not more than count characters where space
     for the terminating ` ' should not be included in count.

RETURN VALUES    [Toc]    [Back]

     The strcat() and strncat() functions return the pointer s.

EXAMPLES    [Toc]    [Back]

     The following appends ``abc'' to ``chararray'':

           char *letters = "abcdefghi";

           (void)strncat(chararray, letters, 3);

     The following example shows how to use strncat()  safely  in
conjunction
     with strncpy(3).

           char buf[BUFSIZ];
           char *input, *suffix;

           (void)strncpy(buf, input, sizeof(buf) - 1);
           buf[sizeof(buf) - 1] = ' ';
           (void)strncat(buf,   suffix,   sizeof(buf)   -   1   -
strlen(buf));

     The above will copy as many  characters  from  ``input''  to
``buf'' as will
     fit.  It then appends as many characters from suffix as will
fit (or none
     if there is no space).  For operations like this, the  strlcpy(3) and
     strlcat(3) functions are a better choice, as shown below.

           (void)strlcpy(buf, input, sizeof(buf));
           (void)strlcat(buf, suffix, sizeof(buf));

SEE ALSO    [Toc]    [Back]

      
      
     bcopy(3),   memccpy(3),  memcpy(3),  memmove(3),  strcpy(3),
strlcat(3),
     strlcpy(3)

STANDARDS    [Toc]    [Back]

     The  strcat()  and  strncat()  functions  conform  to   ANSI
X3.159-1989 (``ANSI
     C'').

OpenBSD      3.6                           July      8,      1997
[ Back ]
 Similar pages
Name OS Title
strcat Linux concatenate two strings
wcsncat Linux concatenate two wide-character strings
wcscat Linux concatenate two wide-character strings
cat FreeBSD concatenate and print files
cat IRIX concatenate and print files
cat OpenBSD concatenate and print files
xstr IRIX extract strings from C programs to implement shared strings
xstr OpenBSD extract strings from C programs to implement shared strings
xstr HP-UX extract strings from C programs to implement shared strings
xstr FreeBSD extract strings from C programs to implement shared strings
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service