i am thinking of taking the first place of the string
and making FindLast(char* str,char c, int n)
then i substract the first place with the place which were returned and save the subtraction
then i compare the length with the length i will get from
MinSubstring(str+1, n, c,&len);
i save in len the minimal length
and return the place where the minimal string starts.
is there any problem in this code
Code:
char*MinSubstring( char *str, int n, char c, int *len)
{
int length,next_length;
char* place,next_place;
place=FindLast(str,c,n);
length=place-str;
if (*str!='\0')
next_place=MinSubstring(str+1,n,c,&next_length);
if (next_length>length)
{
*len=length;
return place;
}
else
{
*len=next_length;
return next_place;
}
}