char *strdup(const char *s);
This convenient little str function
space, and copy into said space, the passed string s
, returning a pointer to said space.
Sure, it's not glamorous or ritzy
, but it's useful
. Meat and potatoes
, if you will.
This is a case of code re-use. The code to copy a string into a new buffer is pretty basic. But it's just complex enough that writing it out a dozen times is a pain, and prone to errors or typo's.