The strdup() function duplicates a string
A standard C function that returns the length of a string.
"Additionally if you have strdup then it is much more convenient than strlen + malloc + strcpy with identical result including the same obligation to free the allocated storage when you no longer need it"
from question "How do I store my substring between strtok tokens in C?"
"As i noted in comments however if you re willing to rely on posix s strdup then that s cleaner than strlen + malloc + and has the same semantics you take responsibility for freeing the memory allocated for the copy"
from question "Conditional jump or move depends on uninitialised value(s) in C"