M
Markus
I am hoping I'm in the right place.
Please help me with my pointer understanding... Using a slightly
altered strcmp function I come up with this:
int mystrcmp ( const char * src, const char * dst)
{
int ret = 0 ;
while( 0 == ret && *dst)
{
ret = (*(unsigned char *)src - *(unsigned char *)dst);
++src;
++dst;
}
.....
}
In regards to just the pointers, it is my understanding that:
1. I will come into this function with addresses to both parameters
(src and dst) which are of type const char.
2. I then go into the while loop and 'cast' the type to unsigned char
for ease of ASCII arithmetic (something like that).
3. Then each the addresses are incremented by one with the ++src
etc., revealing the contents of each to be compared again.
What I'm not understanding, is the * outside of the parans...IE:
^*^(unsigned char *)src - ^*^(unsigned char *)dst
Doesn't the (unsigned char *) point to and dereference the initial and
subsequent addresses???
Thanks for any help,
Markus
Please help me with my pointer understanding... Using a slightly
altered strcmp function I come up with this:
int mystrcmp ( const char * src, const char * dst)
{
int ret = 0 ;
while( 0 == ret && *dst)
{
ret = (*(unsigned char *)src - *(unsigned char *)dst);
++src;
++dst;
}
.....
}
In regards to just the pointers, it is my understanding that:
1. I will come into this function with addresses to both parameters
(src and dst) which are of type const char.
2. I then go into the while loop and 'cast' the type to unsigned char
for ease of ASCII arithmetic (something like that).
3. Then each the addresses are incremented by one with the ++src
etc., revealing the contents of each to be compared again.
What I'm not understanding, is the * outside of the parans...IE:
^*^(unsigned char *)src - ^*^(unsigned char *)dst
Doesn't the (unsigned char *) point to and dereference the initial and
subsequent addresses???
Thanks for any help,
Markus