Query: strncat
OS: netbsd
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
STRCAT(3) BSD Library Functions Manual STRCAT(3)NAMEstrcat, strncat -- concatenate stringsLIBRARYStandard C Library (libc, -lc)SYNOPSIS#include <string.h> char * strcat(char * restrict s, const char * restrict append); char * strncat(char * restrict s, const char * restrict append, size_t count);DESCRIPTIONThe strcat() and strncat() functions append a copy of the nul-terminated string append to the end of the nul-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 VALUESThe strcat() and strncat() functions return the pointer s.EXAMPLESThe 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 ALSObcopy(3), memccpy(3), memcpy(3), memmove(3), strcpy(3), strlcat(3), strlcpy(3)STANDARDSThe strcat() and strncat() functions conform to ISO/IEC 9899:1999 (``ISO C99'').BSDAugust 11, 2002 BSD
Related Man Pages |
---|
strcat(3) - mojave |
strlcat(3) - mojave |
strncat(3) - mojave |
strncat(3) - osx |
strncpy(3) - osx |
Similar Topics in the Unix Linux Community |
---|
Regular expression match |
strcat outputs garbage |
sscanf() weired behaviour |
C program to read n files and append it to a variable. |
What is use of "char __user *buf"? |