this is a function which return -1 if substring is not find and its position if yes:
int find(char*x, char*y)
{
int max_search = strlen(x) - strlen;
int i;
int len_earch = strlen;
if(max_search<0) return -1;
for(i=0;i<max_search;i++)
{
if(!strncmp(x[i],y,len_search)return i;
}
return -1;
}
you'll use it like:
char* a = "hello word";
char* b = "hello";
int pos = find(a,b);
John Fill
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.