I'm getting an error that I can't use the relational operator "==" to test for a string to string match. Is there a different operator needed because of the array (of strings)?
int searchArray(string name, string &firstNameArray); // declares the function
int main()
{
string firstNameArray[7] = { "Jim", "Tuyet", "Ann", "Roberto", "Crystal", "Valla", "Mathilda" }; //declares and intializes the array
string name = "";
cout << "What's your name?";
getline(cin, name);
searchArray(name, firstNameArray[7]); // using the function
return 0;
}
int searchArray(string name, string &firstNameArray) { //defining the function
int position = 0; //declaring and intializing the return variable - positions 0 thru 6 for array elements and position 7 for not in array
for (int i = 0; i < 7; i++) { //looping through the array
if (firstNameArray[i] == name) //**error code "no operator "==" matches these operands
{
position == firstNameArray[i];
}
else
{
position == 7;
}
}
return position;
}