Mail Archives: djgpp/2001/09/28/21:19:11
CBFalconer <cbfalconer AT yahoo DOT com> wrote in
news:3BB50884 DOT 347A4384 AT yahoo DOT com:
> Thank you. I knew there was a reason I made my equivalent
> (revstring) a void function. I just didn't know what it was :-)
The usefulness of a strrev function depends very much on what you intend to
use it for. For example, if your program is looking for palindromes, you
might want to use something like:
strcmp(word, strrev(word));
i which case the in-place nature of the proposed function is really not
helpful. on the other hand, if one wants to use strrev this way, there are
other issues such as: where did the string returned by strrev come from
(similar to strdup). if the memory was allocated dynamically, the caller
needs to remember to free it. can strrev return NULL? if it is allocated
statically, the function is not thread-safe so on and so forth.
the proposed in-place strrev would address a very narrow issue, and provide
a solution to only a very small number of problems. hence, my belief that
it is better for programmers to implement their specific solution.
Of course, it is only my opinion.
Sinan.
--
--------------------------------
A. Sinan Unur
http://www.unur.com/
- Raw text -