Keil Logo

strncpy

Summary
#include <string.h>

char *strncpy (
  unsigned char *dst,         /* destination string */
  const unsigned char *src,   /* source string */
  unsigned int len);          /* max characters to copy */
Description

The strncpy function copies at most len characters from src to dst. Characters are copied until a null character ('\0') is copied or until len characters have been copied. If the length of src is less than len the remaining bytes in dst are padded with null characters ('\0').

Return Value

The strncpy function returns dst.

See Also

strcat, strcpy, strlen, strncat

Example
#include <string.h>
#include <stdio.h> /* for printf */

void tst_strncpy (const unsigned char *s) {
  const unsigned char buf [21];

  strncpy (buf, s, sizeof (buf));
  buf [sizeof (buf) -1] = '\0';
}
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.