strncat - C string.h

C examples for string.h:strncat

Type

function

From

<cstring> 
<string.h>

Description

Appends the first num characters of source to destination, plus a terminating null-character.

Prototype

char * strncat ( char * destination, const char * source, size_t num );

Parameters

Parameter Description
destination Pointer to the destination array.
source C string to be appended.
num Maximum number of characters to be appended.

Return Value

destination is returned.

Demo Code


#include <stdio.h>
#include <string.h>

int main ()//ww w.j  a v a  2 s.  com
{
  char str1[20];
  char str2[20];
  strcpy (str1,"To be ");
  strcpy (str2,"or not to be");
  strncat (str1, str2, 6);
  puts (str1);
  return 0;
}

Related Tutorials