CBFalconer said:
Why do you say this? Take a look at ggets (on my home page, see
the organization header) which can easily return an arbitrary
string. However returning that as the function value would require
an extra, confusing (IMO), input parameter as a place to record
errors.
I said it was tricky, not impossible.
It's tricky, in part, because there are multiple ways to do it, with a
number of tradeoffs. It's a common stumbling block for beginners.
ggets() "returns" an arbitrary string via a char** parameter, and
requires the caller to free the allocated string. Another approach is
to return a char* result and require the caller to free the allocated
string. Yet another approach is to return a pointer to a static array
object, as some of the C standard library functions do (this relieves
the caller of the responsibility of freeing the string, but it has
other problems). Yet another approach is to require the caller to
pre-allocate a buffer and pass a pointer to it, as fgets() does.
This is all much simpler and more convenient in some higher-level
languages; in many of them, you can simply return a string value and
let the caller use it.
This is not meant as a criticism either of C or of ggets, just an
observation.