I'm trying to copy a char16_t*
that's passed into a function but haven't found any way to do that.
foo(char16_t* characters) {
char16_t* copiedCharacters;
//copy characters to copiedCharacters
}
I tried to use strncopy()
but it only copies char*
.
There is a known construction (borrowed from strcpy):
char16_t* str16cpy(char16_t* destination, const char16_t* source)
{
char16_t* temp = destination;
while((*temp++ = *source++) != 0)
;
return destination;
}
Just adjust strcpy implementation
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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.