I am trying to return the number of letter matches. No matter the number of matches, I get a return of no matches. Can anyone help???
#include <iostream>
#include <iomanip>
using namespace std;
int number_right (char let1, char let2, char let3, char let4, char let5, char let6);
int main ()
{
char let1 = 0, let2 = 0, let3 = 0, let4 = 0, let5 = 0, let6 = 0;
//call test function
number_right (let1, let2, let3, let4, let5, let6);
}
int number_right (char let1, char let2, char let3, char let4, char let5, char let6) /*function for number_right with six characters taken. Will
return the number of chacter pairs that are a match*/
{
int set1 = 0; //setting set1 as a int, set at 0
int set2 = 0; //setting set2 as a int, set at 0
int set3 = 0; //setting set3 as a int, set at 0
cout << "Please enter six characters.\n"; //promt the user to enter in six characters
cin >> let1 >> let2 >> let3 >> let4 >> let5 >> let6; //user enters six characters
if (let1 == let4) //if the first and fourth characters entered by the user are the same
{
cout << "The first letter is a match.\n"; //will cout notifying user that the numbers are a match
set1 = set1 + 1; //add one to set1 if the characters are the same
}
if (let2 == let5) //if the second and fifth characters entered by the user are the same
{
cout << "The second letter is a match.\n"; //will cout notifying user that the numbers are a match
set2 = set2 + 1; //add one to set2 if the characters are the same
}
if (let3 == let6) //if the third and sixth characters entered by the user are the same
{
cout << "The third letter is a match.\n"; //will cout notifying user that the numbers are a match
set3 = set3 + 1; //add one to set3 if the characters are the same
}
else //if the characters do not match each other
{
cout << "There is no match.\n"; //advising the user that the characters do not match
}
return (set1 + set2 + set3); //returning the additions of set1, set2 and set 3. This will return the correct amount of pairs matched
}