strndup

Name

strndup -- return a malloc'd copy of at most the specified number of bytes of a string

Synopsis

#include <string.h>

extern char *strndup(const char *string, size_t n);

Description

Return a malloc'd copy of at most n bytes of string. The resultant string is terminated even if no null terminator appears before STRING[N].