Function prototype: extern int memcmp (void * str1, void * str2, unsigned int N)
Parameter description: str1 and str2 are the specified strings to compare the first n Bytes of the two strings.
Database Name: # include <string. h>
Function: compare whether the first n Bytes of the string str1 and str2 in the memory area are the same.
Return Description: return value for str1 <str12 <0; return value for str11 = str12 = 0; return value for str11> str12> 0.
Other Instructions: none.
Instance:
# Include <string. h>
# Include <stdio. h>
Int main ()
...{
Char * str1 = "I'm sky2098, welcome to my website! ";
Char * str2 = "I'm sky2098, please do not call me sky2098! ";
Int inttemp;
Inttemp = memcmp (str1, str2, strlen ("I'm sky2098,"); // compare str1 and str2 in the memory zone before strlen ("I'm sky2098 ,") bytes are equal
If (inttemp = 0)
...{
Printf ("str1 and str2 has n Bytes which are the same as each other! /N ");
}
Return 0;
}
Compile and run in VC ++ 6.0:
Note that memcmp functions implement byte comparison rather than character comparison.
Function prototype: extern int memicmp (void * str1, void * str2, unsigned int count)
Parameter description: str1 and str2 are the specified strings for comparison, and the first count bytes of the two strings are compared, which is case-insensitive.
Database Name: # include <string. h>
Function: compare whether the first count bytes of the string str1 and str2 in the memory area are the same.
Return Description: return value for str1 <str12 <0; return value for str11 = str12 = 0; return value for str11> str12> 0.
Other Instructions: none.
Instance:
# Include <string. h>
# Include <stdio. h>
Int main ()
...{
Char * str1 = "I'm sky2098, welcome to my website! "; // The two strings have the same meaning, but are case-insensitive.
Char * str2 = "I'm sky2098, welcome to my website! ";
Int inttemp;
Inttemp = memicmp (str1, str2, strlen ("I'm sky2098, welcome to my website! "); // Compare str1 and str2 in the memory zone before strlen (" I'm sky2098, welcome to my website! ") Are the bytes equal?
If (inttemp = 0)
...{
Printf ("str1 and str2 has n Bytes which are the same as each other! ");
}
Return 0;
}
Compile and run in VC ++ 6.0:
The memicmp function is case-insensitive during comparison.