Find Partial String in String Vector
<p>I have a vector of students, each element consists of ID and test answers.</p>

<p>ABCTFTFTF (ABC = ID, TFTFTF = Answers)</p>

<p>I am trying to retrieve just the block of TFTFTF's and compare them against a string that consists of the correct string of answers.</p>

<p>I understand it must be:</p>

<ul>
<li><p>students[i]</p></li>
<li><p>create substring (start of answers = position 10, ends at position 30)</p></li>
<li><p>compare substring</p></li>
<li><p>act on comparison</p></li>
</ul>

<p>But I am really struggling syntactically, could anyone point me in the right direction?</p>

<ul>
<li><strong>EDIT</strong></li>
</ul>

<p>tried:</p>

<pre><code>void getResults()
{

    string found;



 for(int i = 0; i &lt; 150; i++)
    {
        found = students[i].find(answers);
        if(found == answers)
        {
            cout &lt;&lt; "Student: " &lt;&lt; i &lt;&lt; "Passed" &lt;&lt; endl;
        }
        else
        {
            cout &lt;&lt; "Student: " &lt;&lt; i &lt;&lt; "Failed" &lt;&lt; endl;
        }
    }
}
</code></pre>

<p>Personal project -- not homework </p>

<p>I am following this daily c++ projecs thread:</p>

<p><a href="http://www.cplusplus.com/forum/beginner/75558/" rel="nofollow">http://www.cplusplus.com/forum/beginner/75558/</a></p>

<p>Mock Data:</p>

<pre><code>OMXIZGWA TTFTFTFFTFTTFFFTTFTF
XKVNYUVZ F FTFFFFFT TFFTTTFFF
GGVDSSTQ TFFFTF FTTF TF  TFFT
XPYDXVIQ FFTTFT FTFT TFFTTTFT
XVFUMFZL TTFFTFFTFFTFF FFTFFT
</code></pre>

<p>(white char = no answer given)</p>

<p><strong>* EDIT ANSWER</strong></p>

<pre><code>void getResults()
{

    string found;
    string foundSubString;

    for(int i = 0; i &lt; 150; i++)
    {
        found = students[i];

        foundSubString = found.substr (9,20);


        if(foundSubString == answers)
        {
            cout &lt;&lt; "Student: " &lt;&lt; i &lt;&lt; "Passed" &lt;&lt; endl;
        }
        else
        {
            cout &lt;&lt; "Student: " &lt;&lt; i &lt;&lt; "Failed" &lt;&lt; endl;
        }
    }
</code></pre>
