string problem

HI. I have string: TATAGAGCTAGCTAGCTAGCTAGCTAGC
Is there easy way to look for line like GATA in string and return index where
that line start ?

using this loop ?
1
2
3
 for (auto it = bla.begin(); it != bla.end(); it++) 
{
}
This is nice but i cant used this.
I must find it be loop for.
You did ask for easy way. That is string::find()

Note that there are string::substr() and operator== that tells whether two strings are identical. Alas, you must use a loop.


You must use the think instead. You have to implement equivalent of string::find() yourself.

Nested loops. The outer iterates over the string positions that a match could start from. The inner tests whether there is a match.
Last edited on
Registered users can post here. Sign in or register to post.