#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 --*/
谢谢欣赏,欢迎指正。
阅读(1044) | 评论(0) | 转发(0) |