Stack Overflow Asked by MR.needhelp on March 8, 2021
I got an error on the line *saveRow = row;
which say indirection requires pointer operand ('int' invalid)
Here’s the code.
bool validateUser (std::string theAccounts[5][7], string username, string password, int &saveRow)
{
bool passed = false;
int user = 0;
int pass = 3;
int row = 0;
for (int row = 0; row <= 4; row++) // For loop passing through theAccounts array finding matching username + password.
{
if ((username == theAccounts[row][user]) && (password == theAccounts[row][pass]))
{
passed = true;
*saveRow = row;
}
}
return passed; // Returns false if no match is found.
}
The parameter saveRow
is a reference, not a pointer. You can't dereference a reference, only a pointer. Simply assigning to a reference will assign to the variable that it is referencing.
bool validateUser (std::string theAccounts[5][7], string username, string password, int &saveRow)
{
bool passed = false;
int user = 0;
int pass = 3;
int row = 0;
for (int row = 0; row <= 4; row++) // For loop passing through theAccounts array finding matching username + password.
{
if ((username == theAccounts[row][user]) && (password == theAccounts[row][pass]))
{
passed = true;
saveRow = row;
}
}
return passed; // Returns false if no match is found.
}
Answered by Ted Klein Bergman on March 8, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP