Paragraphs comparison C++
<p>I'm new to C++ and I have same problem on doing a text comparison program.</p>

<p>I used vector to store my string array since we don't know the length of the paragraphs.
I created words and words1 for inputting  2 paragraphs from 2 txt. files.
words is for the original one as the reference.
words1 is the user input, the one we need to compare it to the original one to check how many mistakes the user did.</p>

<pre><code>while (fin1 &gt;&gt; str) 
    {                  
        words1.push_back(str);
    }
    fin.close();
</code></pre>

<p>Then I used a for loop to do the comparison.</p>

<pre><code>for (int i = 0; i &lt; words.size(); ++i)
    {
        if (words.at(i) != words1.at(i))
            count++;
    }
</code></pre>

<p>But, the problem is that if the length of two paragraphs is different, it will returns me a error since the words.size() is different. </p>

<p>For examples, 
The original txt(words) : Today is Wednesday, I'm so happy to talk to you guys.
The one input by users(words1) : Today is <strong><em>Tuesday</em></strong>, I'm so happy to <strong><em>tell</em></strong> to you guys.</p>

<p>This is fine, my program can show me the number of mistakes is 2.
But if there is any missing words or some extra words. The program will just crush.</p>

<p>Examples:
The original txt : 
Today is Wednesday, I'm so happy to talk to you guys.</p>

<p>The one input by users : 
Today is Tuesday, I'm to talk to you guys.</p>

<p>Tuesday doesn't match Wednesday and 'happy' and 'to' are missing
So it should be count as 3 errors.</p>

<p>Or</p>

<p>The one input by users :
Today is Tuesday, I'm so happy to <strong><em>to to</em></strong> talk to you guys.</p>

<p>Tuesday doesn't match Wednesday and two extra 'to'. 
So it should be counted as 3 errors.</p>

<p>I'm not sure if there is a way to count this kind of errors</p>

<p>So the easiest way to solve the problem is just to add some dummy into the shorter array to make sure their length as the same?</p>

<p>Hope somebody can discuss with me:) Thank you!</p>