C++/requesting for help in the following ..
iam a bioinformatics student have knowledge in biology and little in programming..
sir, please help me in the following problem in c programming .
we have 20 aminoacids like(a,b,c,d....), such that the combinations of occuring pairs is 20*20=400 chances of pairs
like(ab,ac,ad,bc,bd,ba,...). so i need to calculate bigrams which are repetitively occuring(example:ab occurs 10 times,bc occurs 20 times) in given length(for example 300 element s of aminoacids like(abcddcbbccaaa....) of file?
so, please help me in the above .as i capable to write upto get the bigrams but i have a problem that how to count these repeated bigrams by using file handling.
upto know to get the bigrams my code is as follows...
printf("enter the string");
printf("enter the 2nd string");
sir ,please help me as early as possible.
thank you for your help.
This exercise sounds like you want to find a substring in a larger string, and count them. C provides a nice function for this: strstr.
Use strstr to find the substring. If it returns NULL, you've reached the end of the string. If not, it is the point of the match. To resume searching to the end, take the return pointer and add the length of the match string:
char *string; // large string to search
char *part; // part to count in string
count = 0; // Number of parts in string
position = string;
while( position )
position = strstr( position, part );
if( position != NULL )
position += strlen( part ); // resume after match