0
Using strcpy and strcat. Or sprintf. Or strlen+memcpy. There are more than solutions.
They do different things, so they are uncomparable.
PS: strcpy can be implemented with strlen+memcpy:
char *strcpy (char *dest, const char *src)
{
size_t len;
len= strlen (src);
memcpy (dest, src, len);
return dest;
}
In short, you don't. strncpy is deemed unsafe as it has potential to cause buffer overruns. To copy strings safely in C++, use std::string instead.
For examples and syntax, see related links, below.
strcpy
char* strcpy(const char* src, char* dst) { char* tmp = dst; while ((*dst++ = *src++) != '\0'); return tmp; }