实现strstr函数

来源:互联网 发布:java socket监听端口 编辑:程序博客网 时间:2024/05/28 15:08

int   strstr(char *h,   char *n)
{
  int i=0,j=0;


  while ( h[i]!='/0' && n[j] != '/0' )
{
  if (h[i]== n[j])
 {
   i++;
          j++;

 }
   else
 {
   i++;
          j=0;

 }

}

if (n[j]=='/0')

return i-j;

else return -1;

}

原创粉丝点击