#include <string.h>
int p_strcmp(const void *pv1, const void *pv2)
{
char * const * v1 = pv1;
char * const * v2 = pv2;
return strcmp(*v1, *v2);
}
Either you are not understanding me or I am not able to understand this
<p_strcmpthing. This is your code:
compare these 2 paragraphs:
In theory, you get a <pointer to const voidand you use it to initialize
a <pointer to a const pointer to char. In practice, you get a <pointer
to a pointer to charand you are using it to initialize a <pointer to a
const pointer to charand then dereference it to a <const pointer to
char>.
Because you already know that the input argument will be <char**so we
can simply dereference it and get a <char*which could be used for
<strcmpsince <strcmpdoes not require a <const pointer>. Hence It
could be simply this:
int p_strcmp(const void *pv1, const void *pv2)
{
return strcmp(*pv1, *pv2);
}
I need explanation on this as it<p_strcmpcode is biting me
from the very 1st day I saw it in section 13.8 of the FAQ and I still
can't seem to comprehend the WHY of it.
--
http://lispmachine.wordpress.com/
my email ID is at the above address
--
http://lispmachine.wordpress.com/
my email ID is at the above address