i want solution program for this program......

Given a string and a non-empty substring sub, compute the largest substring which starts and ends with sub and return its length.

test cases:
strDist("catcowcat", "cat") → 9
strDist("catcowcat", "cow") → 3
strDist("cccatcowcatxx", "cat") → 9

i want solution program for this program......

Given a string and a non-empty substring sub, compute the largest substring which starts and ends with sub and return its length.

test cases:
strDist("catcowcat", "cat") → 9
strDist("catcowcat", "cow") → 3
strDist("cccatcowcatxx", "cat") → 9

1> we are not here to do your homework

2> use strncmp() to solve your problem.

3> Try to solve it yourself. Its not very hard.

4> if u are stuk somewhere just post your problem here. We can help.

gud luck............

>>wanted solution

I want a million dollars too -- will you give it to me ??? Kindly deposit it into my paypal account.

Hint to the solution: use strstr() to find the substring, then subtract two pointers (return value of strstr() and the original pointer)

char str = "Hello World";
strstr( str, "World") - str + strlen("World");

The above will crash if "World" is not contained in str.

commented: couldn't be better :) +1
commented: LOL. Yeah, I'll take some too! +1