我正在尝试复制一个char16_t*
传递给函数但没有找到任何方法来做到这一点。
foo(char16_t* characters) {
char16_t* copiedCharacters;
//copy characters to copiedCharacters
}
我尝试使用strncopy()
,但它只复制char*
.
有一个已知的结构(从 strcpy 借来的):
char16_t* str16cpy(char16_t* destination, const char16_t* source)
{
char16_t* temp = destination;
while((*temp++ = *source++) != 0)
;
return destination;
}
只需调整strcpy 实现
char16_t *mystrcpy(char16_t *dest, const char16_t *src)
{
unsigned i;
for (i=0; src[i] != '\0'; ++i)
dest[i] = src[i];
dest[i] = '\0';
return dest;
}