strncat

Appends a specified number of characters of one string to another string

Local Servers:nonblocking
Remote Servers:N/A
Classification:ANSI
Service:String Manipulation

Syntax

  #include <string.h>  
   
  char *strncat  (  
     char         *dst,   
     const char   *src,   
     size_t        n);
  

Parameters

dst
(OUT) Points to the string to which to append the characters.
src
(IN) Points to the string containing the characters to be appended to the string pointed to by dst.
n
(IN) Specifies the maximum number of characters to append.

Return Values

The strncat function returns the value of dst.

Remarks

The strncat function appends not more than n characters of the string pointed to by src to the end of the string pointed to by dst. The first character of src overwrites the NULL character at the end of dst. A terminating NULL character is always appended to the result.

See Also

strcat

Example

  #include <string.h>  
  #include <stdio.h>  
   
  char    buffer[80];  
  main ()  
  {  
     strcpy (buffer, "Hello ");  
     strncat (buffer,"world", 8);  
     printf ("%s\n", buffer);  
     strncat (buffer, "*************", 4);  
     printf ("%s\n", buffer);  
  }
  

produces the following:

  Hello world  
  Hello world****