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