De RAD Studio
Aller à : navigation, rechercher

Remonter à string.h - Index

Header File



Memory and String Manipulation Routines


unsigned char *_mbsnbcpy(unsigned char *dest, unsigned char *src, size_t maxlen);


The _mbsnbcpy function copies at most maxlen number of bytes from the src buffer to the dest buffer. The dest buffer is null terminated after the copy.

It is the user's responsibility to be sure that dest is large enough to allow the copy. An improper buffer size can result in memory corruption.

Return Value

The function returns dest.


 #include <mbstring.h>
 /* Creates a copy of the MBCS string */
 char* dupe_mb_string(char* str)
   /* Obtain the input string's length */
   int str_len = strlen(str);
   /* Do nothing on the empty string */
   if (!str || !str_len)
     return NULL;
   /* Allocate enough memory for the new string and call the copy routine */
   return _mbsnbcpy((char*)malloc(str_len + 1), str, str_len);