日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java memcmp_memcmp,memicmp函数

發布時間:2023/12/2 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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函数的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。