I'm trying to search an array of objects to find a match for a string that a user types in, however no matter what the user types it still displays an error, even if the string matches exactly.
if string doesnt match any in array, print the if, else print the info
void accountInfo(Bank MaqBank, ofstream &c_out)
{
Account Account; string AcctType, AcctNum; double AcctBal;
Depositor Depstr; string Social;
Name DepstrName; string First, Last;
int Index;
//Get user input for an SSN
cout << "Enter the social security number of a depositor whose account you wish ""to check(INCLUDE DASHES): "; cin >> Social;
//Send SSN to MaqBank member function findAccountSSN to find a match
Index = MaqBank.findAccountSSN(Social);
if(Index != -1) //If a match is not found
{
c_out << "Depositor not found OR invalid social security number entered." <<
endl;
cout << "Returning to main menu." << endl;
}
else //If a match is found
{
Account = MaqBank.getAccount(Index);
AcctType = Account.getAcctType();
AcctNum = Account.getAcctNum();
AcctBal = Account.getAcctBal();
Depstr = Account.getDepstr();
Social = Depstr.getSSN();
DepstrName = Depstr.getName();
First = DepstrName.getFirst();
Last = DepstrName.getLast();
c_out << "Depositor found - Information below" << endl;
c_out << "Depositor name: " << First << " " << Last << endl;
c_out << "Account Number: " << AcctNum << endl;
c_out << "Account Type: " << AcctType << endl;
c_out << "Account Balance: $" << AcctBal << endl;
}
}