SYNOPSIS
#include
char *strdup(const char *s);
DESCRIPTION
This convenient little
str function will
malloc space, and copy into said space, the passed string
s, returning a pointer to said space.
NOTES
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.