Hello , I wrote a sol. for you. Just go thru this. It will search a given substring in given string & print how many times this substring are there...
int main(){ char *str1="How much wood would a woodchuck chuck if a woodchuck could chuck wood?"; int i; char *ptr1="wood"; findseqcount(str1,ptr1); return 0; } findseqcount(const char *str,char *ptr){ int count=0,i,j; int n=strlen(str); int len=strlen(ptr); printf("n:%d len:%d\n",n,len); char narr[len]; char *arr; while((n-->0) && *str!='\0'){ int len=strlen(ptr); i=0; char *p=ptr; while(*p!='\0'){ if((*p==*str)){ narr[i] = *str; p++; i++; } else{ p=ptr; i=0; } str++; } if(*str!='\0'){ arr=narr; while(len-->0 && *arr!='\0'){ printf("%c",*arr); arr++; } printf("\n"); } } } Thanx...!!! --- Peeyush Bishnoi On 5/30/07, Phil <[EMAIL PROTECTED]> wrote: > > > What I am trying to do is given a string, find the sets of identical > substrings within the string (of a certain minimum length). > > Examples: > in "abracadabra", we have 2 occurrences of "abra" > in "humpty dumpty", we have 2 occurrences of "umpty" > in "How much wood would a woodchuck chuck if a woodchuck could chuck > wood?", we have 2 occurrences of " a woodchuck ", 4 of "chuck ", 4 of > " wood", 2 of "ould " > > I have searched the net and found some info on things like Longest > Common Subsequence/SubString, suffix trees, and Lev. distance, but can > anyone give me any specific pointers or any tips/ideas/shortcuts? > Thanks. > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---