
Originally Posted by
zeco
I understand everything except one part
Code:
bool bCompare(const BYTE* pData, const BYTE* bMask, const char* szMask)
{
for(;*szMask;++szMask,++pData,++bMask)
if(*szMask=='x' && *pData!=*bMask )
return false;
return (*szMask) == NULL;
}
Ok. which parts specifcally...

Originally Posted by
zeco
Well starting with :
if(*szMask=='x' && *pData!=*bMask )
return false;
Does it mean, If blah blah is true, just return false, ignoring the rest of the function.
Well to understand this we need to understand the part above it too. So all of this:
Code:
bool bCompare(const BYTE* pData, const BYTE* bMask, const char* szMask)
{
for(;*szMask;++szMask,++pData,++bMask)
if(*szMask=='x' && *pData!=*bMask )
return false;
This confused me a little too. This guy (whoever wrote the code) put the "*"(pointer sign) next to the type instead of the variable. See here:
Code:
bool bCompare(const BYTE* pData, const BYTE* bMask, const char* szMask)
See I would have done it like this:
Code:
bool bCompare(const BYTE *pData, const BYTE *bMask, const char *szMask)
Ok so now we know that these are pointers we need to know what this statement does:
Code:
for(;*szMask;++szMask,++pData,++bMask)
if(*szMask=='x' && *pData!=*bMask )
return false;
Ok lets break it down. We will start with the
for loop:
Code:
for(;*szMask;++szMask,++pData,++bMask)
It seems like as long as the
value("*" that's what that little thing means) of pointer
szMask is not "0" the loop will keep executing.
Remember Everytime it executes
szMask,
pData, and
bMask all get incremented.
Code:
if(*szMask=='x' && *pData!=*bMask )
return false;
All this means is that if the
value of szMask is x (*szMask=='x') and (&&)
the value of pData does not equal the value of bMask(*pData!=*bMask)....
then this boolean funtion will return
false
Next question?

Originally Posted by
zeco
and for return (*szMask) == NULL;, does that mean, return the value if it is null? Or something to that effect.
Well lets break it down again:
Code:
return (*szMask) == NULL;
return can only return a boolean type because the function specifies that it returns a boolean. If it returned anything else there would be an erroe and this would not compile
Code:
return (*szMask) == NULL;
The == operator will evaluate the values on both sides of it to see if they are equal in value and then return a
true or
false (boolean) value.
Code:
return (*szMask) == NULL;
(*szMask) since
szMask is a pointer to a byte,
*szMask will return the value of that byte (byte values are usually char).
NULL is the character that marks the end of a string. I'm unsure if its zero but basically...
This whole express will evaluate to true or false depending if
(*szMask) ==
NULL
sorry I couldn't explain further got to get to class. xD