One of your requirement was "....and keep a count of the digits that match .... "
but your code is silent on this.
I suggest you can use a simple int which is initialized at start and would be incremented in the " if part of comparison ( a == A)" of the code.
The value of the variable after all such ifs ( i.e ..e == E )
would be value of digits that are same and the same can be printed.
Further ... knowledge of arrarys that definitely simplify the code.
I suggest you to refer to K & R - the C programming text - concept wise it is the best and price wise affordable aswell.
you can declare a single dimensional array as
int lottery [5] // it can hold only 5 values.
int user[5]
and for receiving the values
int i = 0;
while ( i < 5) {
cin >> lottery[i]
i++;
}
... like wise for user array and now you tell me on the comparison logic using arrays.
Look out for info at the following link
http://www.daniweb.com/forums/thread50370.html
at one stage the info contained was of great help to me.