Comparing lines of strings from a file
<p>I have a file that I have read and I want to read each individual line as if it were a string and compare each line to find certain keywords and if I find those certain keywords, take everything within those keywords and make a new string out of it. It is possible to have more than one line with the same keywords, so I would like to create separate strings...</p>

<p>I have some ugly looking code right now that it would be embarrassing to put here, can someone point me in the right direction of how to do this...</p>

<p>I can put my code here if you like, but I'll have to explain it a lot.</p>

<blockquote>
  <p>AGU UAC AUU GCG CGA UGG GCC UCG AGA CCC GGG UUU AAA GUA GGU GA</p>
  
  <p>GUU ACA UUG CGC GAU GGG CCU CGA GAC CCG GGU UUA AAG UAG GUG A</p>
  
  <p>UUA CAU UGC GCG  M  GGC CUC GAG ACC CGG GUU UAA AGU AGG UGA</p>
  
  <p>UGG  M  AAA UUU GGG CCC AGA GCU CCG GGU AGC GCG UUA CAU UGA</p>
</blockquote>

<p>This would be part of my text file. I want to find 'M' and then find instances of: 1) UAA, 2) UAG, or 3) UGA. And make each one a separate string so that I can compare their lengths. I tried using the assignment operator, but it would print out the same string every time.  </p>

<p>ED. I guess what I would like to do is just find any instance of 'M', when I do, I would like to make that whole line into a string so I can compare the strings.</p>

<pre><code>ifstream code_File ("example.txt");   // open text file.
if (code_File.is_open()) {
    while (code_File.good()) {


        getline(code_File,line);    //get the contents of file 
        cout  &lt;&lt; line &lt;&lt; endl;     // output contents of file on screen.


            found = line.find_first_of('M', 0);               // Finding start code
        if (found != string::npos) {
           code_Assign.assign(line, int(found), 100);        //assign the line to code_Assign and print out string from where I found the start code 'M'.

            cout &lt;&lt; endl &lt;&lt; "code_Assign: " &lt;&lt; code_Assign &lt;&lt; endl &lt;&lt; endl;
</code></pre>
