在内存在查找子串
来源:互联网 发布:核盾网络验证 编辑:程序博客网 时间:2024/05/29 12:51
//在一段内存缓冲中查找指定字符串的位置,从头开始查找,区分大小写
//返回第一个找到的位置。
//str1 - 内存缓冲的头指针
//nLen1 - 内存缓冲长度
//str2 - 要查找匹配的字符串
bool bcompi(char byA, char byB)
{
if (byA - byB == 0)
{
return true;
}
else
{
if (!((byA >= 'A' && byA <= 'Z') || (byA >= 'a' && byA <= 'z')))
return false;
if (!((byB >= 'A' && byB <= 'Z') || (byB >= 'a' && byB <= 'z')))
return false;
if ((byA - byB == 'a' - 'A') || (byB - byA == 'a' - 'A'))
return true;
else
return false;
}
}
char * memistr(const char * str1, int nLen1, const char * str2)
{
if ((NULL == str1) || (NULL == str2) || (nLen1 <= 0))
return NULL;
long ls1 = nLen1;
char *cp = (char *) str1;
char *s1, *s2;
if ( !*str2 )
return((char *)str1);
while (ls1 > 0)
{
s1 = cp;
s2 = (char *) str2;
while ( *s1 && *s2 && bcompi(*s1, *s2) )
s1++, s2++;
if (!*s2)
return(cp);
cp++;
ls1--;
}
return(NULL);
//返回第一个找到的位置。
//str1 - 内存缓冲的头指针
//nLen1 - 内存缓冲长度
//str2 - 要查找匹配的字符串
bool bcompi(char byA, char byB)
{
if (byA - byB == 0)
{
return true;
}
else
{
if (!((byA >= 'A' && byA <= 'Z') || (byA >= 'a' && byA <= 'z')))
return false;
if (!((byB >= 'A' && byB <= 'Z') || (byB >= 'a' && byB <= 'z')))
return false;
if ((byA - byB == 'a' - 'A') || (byB - byA == 'a' - 'A'))
return true;
else
return false;
}
}
char * memistr(const char * str1, int nLen1, const char * str2)
{
if ((NULL == str1) || (NULL == str2) || (nLen1 <= 0))
return NULL;
long ls1 = nLen1;
char *cp = (char *) str1;
char *s1, *s2;
if ( !*str2 )
return((char *)str1);
while (ls1 > 0)
{
s1 = cp;
s2 = (char *) str2;
while ( *s1 && *s2 && bcompi(*s1, *s2) )
s1++, s2++;
if (!*s2)
return(cp);
cp++;
ls1--;
}
return(NULL);
}
0 0
- 在内存在查找子串
- Android 在Activity里查找某个子View是否存在
- 判断子串的存在
- kmp 子串查找
- string 查找子串
- 原串中查找子串
- java查找子串
- 子串查找
- 查找子串
- 查找字符子串
- 子串查找问题
- 查找子串函数
- 查找子串
- 查找子串
- 最小子串查找
- 查找子串
- 查找子串
- 子串查找
- 运用HTML5+CSS3做的登录页面
- 程序猿之--我的书籍阅读目标
- 配置spring4+spring mvc+hibernate4+hadoop1.2
- 信息安全基础知识(一)保密性,完整性,端点认证
- 使用percona监控mysql ==> zabbix监控系列
- 在内存在查找子串
- android多媒体之播放器:检索sd卡的所有video
- 如何高雅的旋转textview文字显示
- J2EE规范JDBC与JNDI
- 线程 (detach的作用)
- Android 有输入框的页面,一打开就会弹出输入法,最简单屏蔽办法
- Openvswitch手册(2): OpenFlow Controller
- Windows下安装Atlassian-Jira-6.0.4并破解汉化(只需2步,另附图解)
- 修改MySQL最大连接数