n bytes of str
strndup
fn
string strndup(string str, size_t n)Duplicates the first n bytes of a string, returning a newly-allocated buffer n + 1 bytes long which will always be nul-terminated. If str is less than n bytes long the buffer is padded with nuls. If str is NULL it returns NULL.
To copy a number of characters from a UTF-8 encoded string, use funcGLib.utf8_strncpy instead.
Parameters
str | the string to duplicate |
n | the maximum number of bytes to copy from str |
Returns
a newly-allocated buffer containing the first