[英]Copy from char16_t* to char16_t*
我正在尝试复制已传递到函数中的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;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.