C语言 实现strstri不区分大小写查找字符串


char* strstri(char * inBuffer, char * inSearchStr)
{
    char*  currBuffPointer = inBuffer;

    while (*currBuffPointer != 0x00)
    {
        char* compareOne = currBuffPointer;
        char* compareTwo = inSearchStr;
        //统一转换为小写字符
        while (tolower(*compareOne) == tolower(*compareTwo))
        {
            compareOne++;
            compareTwo++;
            if (*compareTwo == 0x00)
            {
                return (char*) currBuffPointer;
            }

        }
        currBuffPointer++; 
    }
    return NULL;
}
文章来自:http://blog.csdn.net/jeanphorn/article/details/44856317
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3