title: Count the number of matching elements in two arrays C++
body: <p>I'm working on a homework assignment for Comp Sci I, and I've tried literally everything I could find on the internet and in my textbook in an attempt to count the number of matching elements in two C++ arrays. I simply can't find a way to make my code count the number of matching elements in two arrays of the same size (same value, same position). For instance, if array1 has 5, 4, 3, 2, 1, and array2 has 1, 2, 3, 4, 5, there is one matching element, the 3. How can I get my code to perform this seemingly simple task? </p>
  
  <p>Couldn't find an answer anywhere. My textbook only shows how to see if the arrays match exactly without counting the number of matches, and I haven't been able to find anyone else with this exact question for C++.</p>
  
  <p>Here's my function so far:</p>
  
  <pre><code>int matchCounter(int lottery[5], int user[5], int matches, int SIZE)
  {
      int count = 0;
  
      for (count &lt; SIZE; count++;)
      {
          if (lottery[count] == user[count])
          {
              matches++;
          }
  }
  
      return matches;
  } // end matchCounter
  </code></pre>
  
  <p>SIZE is a constant that equals 5, by the way. It would seem that this should work, but every time I run the program, it displays 0 matches, even in there are some matches. If anyone could help me out, I would be forever in your debt. Seriously, there's got to be some incredibly simple thing I'm just not seeing. Thanks for you help in advance.</p>