|
发表于 2012-4-26 08:10:33
|
显示全部楼层
/***********************字符串查找********************************
*功 能: 查找字符串
*形 参: char *s, char *t ;在s中查找t
*返 回 值: s_temp(t在s中的位置)成功 0 (失败 )
*备 注:
*****************************************************************/
char *mystrstr(char *s, char *t)
{
char *s_temp ; /*the s_temp point to the s*/
char *m_temp ; /*the mv_tmp used to move in the loop*/
char *t_temp ; /*point to the pattern string*/
if (s == 0 ||t == 0) return 0;
for (s_temp = s; *s_temp != '\0'; s_temp++)
{
m_temp = s_temp;
for (t_temp = t; *t_temp == *m_temp; t_temp++, m_temp++)
if (*t_temp == '\0') return s_temp;
if (*t_temp == '\0') return s_temp;
}
return 0;
} |
|