java memcmp_memcmp,memicmp函数
函數(shù)原型:extern int memcmp(void *str1, void *str2, unsigned int n)
參數(shù)說明:str1和str2為指定作比較的字符串,比較兩個(gè)字符串的前n個(gè)字節(jié)。
所在庫名:#include
函數(shù)功能:比較字符串str1和str2在內(nèi)存區(qū)域中的的前n個(gè)字節(jié)是否相同。
返回說明:當(dāng)str1str12時(shí),返回值>0。
其它說明:暫時(shí)無。
實(shí)例:
#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!";
intinttemp;
????inttemp=memcmp(str1,str2,strlen("I'm?sky2098,"));//比較str1和str2在內(nèi)存區(qū)中前strlen("I'm?sky2098,")個(gè)字節(jié)是否相等if(inttemp==0)
{
??????printf("str1?and?str2?has?n?bytes?which?are?the?same?as?each?other!/n");
???}return0;
}
在VC++ 6.0? 編譯運(yùn)行:
尤其注意了,memcmp函數(shù)實(shí)現(xiàn)的是字節(jié)的比較,而不是字符的比較。
函數(shù)原型:extern int memicmp(void *str1, void *str2, unsigned int count)
參數(shù)說明:str1和str2為指定作比較的字符串,比較兩個(gè)字符串的前count個(gè)字節(jié),不區(qū)分大小寫。
所在庫名:#include
函數(shù)功能:比較字符串str1和str2在內(nèi)存區(qū)域中的的前count個(gè)字節(jié)是否相同。
返回說明:當(dāng)str1str12時(shí),返回值>0。
其它說明:暫時(shí)無。
實(shí)例:
#include
<
string
.h
>
#include
<
stdio.h
>
int
main()
{
char*str1="I'm?sky2098,welcome?to?my?website!";??//兩個(gè)字符串含義相同,但是大小寫不同
char*str2="I'm?SKY2098,WELCOME?TO?MY?website!";
intinttemp;
????inttemp=memicmp(str1,str2,strlen("I'm?sky2098,welcome?to?my?website!"));//比較str1和str2在內(nèi)存區(qū)中前strlen("I'm?sky2098,welcome?to?my?website!")個(gè)字節(jié)是否相等if(inttemp==0)
{
??????printf("str1?and?str2?has?n?bytes?which?are?the?same?as?each?other!");
???}return0;
}
在VC++ 6.0? 編譯運(yùn)行:
memicmp函數(shù)在比較的時(shí)候是不區(qū)分字母大小寫的。
總結(jié)
以上是生活随笔為你收集整理的java memcmp_memcmp,memicmp函数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: thread java 关闭_怎么在ja
- 下一篇: sql双表查询java代码_原生sql