Sunday, September 26, 2010

my_memicmp from internet

int my_tolower(char ch)

{

if(ch >= 'A' && ch <= 'Z')

return (ch + 0x20);

return ch;

}

int my_memicmp(const void *buffer1,const void *buffer2,int count)

{

int f = 0;

int l = 0;

while (count--)

{

if ( (*(unsigned char *)buffer1 == *(unsigned char *)buffer2) ||

((f = my_tolower( *(unsigned char *)buffer1 )) ==

(l = my_tolower( *(unsigned char *)buffer2 ))) )

{

buffer1 = (char *)buffer1 + 1;

buffer2 = (char *)buffer2 + 1;

}

else

break;

}

return ( f - l );

}

參考:

參考來源:

"int my_memicmp(const void *buffer1,const void *buffer2,int count)"
- memicmp ( )【C语言库函数源代码】 - string.h - ammana_babi (在「Google 網頁註解」中檢視)

No comments: