An example says more than thousand words:
unsigned char *hello = (unsigned char*)malloc(STR_LEN * sizeof(unsigned char));
const char *str= "haha";
memcpy(hello, str, strlen(str) + 1);
How can I print the content of the whole hello
-variable (printf("%s",..)
would only respect the part before the \0
-termination and not all STR_LEN
characters).