Chinaunix首页 | 论坛 | 博客
  • 博客访问: 185022
  • 博文数量: 36
  • 博客积分: 230
  • 博客等级: 二等列兵
  • 技术积分: 352
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-22 18:09
文章分类

全部博文(36)

文章存档

2013年(29)

2011年(5)

2010年(2)

我的朋友

分类: C/C++

2013-03-22 12:07:05

 #include
 #include
 #include
char *find_str(char *m_str, char *s_str)
{
  int m_len, s_len;
  int i=0, j=0;
  int count = 0;
  m_len = strlen(m_str);
  s_len = strlen(s_str);
 
 for (i=0; i
  {
     if (m_str[i] == s_str[0])
     {   int a_len = i;
         count = 1;
   while ((m_str[++a_len] == s_str[++j]) && (j    count++;
   printf("Count is %d \n", count);
 if (count == s_len)
         return m_str+i;
 else continue;
    }
  }
   printf("No string found !\n");
   return NULL; 
 }
//------
int main()
{
   char a[50] = "12345abcd";
   char b[] = "34";
   printf("Output is %s \n", find_str(a, b)); 
   return 0;
}
/*--   E  --*/
谢谢欣赏,欢迎指正。
阅读(1007) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~