C++ VC strstr函数的仿真

来源:网络时间:2011-08-04

  char *strstr(register char *buf, register char *sub)

  {

  register char *bp;

  if (!*sub) return buf;

  for (;;)

  {

  if (!*buf)  break;

  bp = buf;

  for (;;)

  {

  if (!*sub) return buf;

  if (*bp++ != *sub++) break;

  }

  sub -= (unsigned long) bp;

  sub += (unsigned long) buf;

  buf += 1;

  }

  return 0;

  }

意见反馈
发表评论

最新评论(共0条)