I'm trying to do this for my school, instead of searching for the account number to find the customer, I'm having to find the customer name instead..The usual strcmp ( customerNames[index], searchCustomer ) == 0 ) doesn't work on this. It seems that is only for one value, while this customerNames array that I have has 4 different preset names, plus whatever you add to it in run-time. Any help is appreciated ;)
int main()
{
int mainMenuSelection;
int accountArray[SIZE] = {1202, 5841, 5644, 5481};
double balanceArray[SIZE] = {450.23, 541.25, 1027.27, 108.50};
char customerNames[SIZE][25] = {"George Washington", "John Smith", "Jane Smith", "Adam Smith"};
int index;
mainMenu(accountArray, balanceArray, customerNames);
system("pause");
return 0;
}
void searchByName ( int accountArray[], double balanceArray[], char customerNames[][25])
{
char searchCustomer;
int index = 0, found = -1;
double amount = 0;
printf ("Enter the account to search for:");
fflush ( stdin );
scanf ("%[^\t\n]s", &searchCustomer);
while ( index < SIZE )
{
if ( customerNames[index] == searchCustomer )
{
found = index;
break;
}
index++;
}
if ( found == -1 )
{
printf ("That account doesn't exist!\n\n");
system("pause");
bankerSide(accountArray, balanceArray, customerNames );
}
else
{
printf ("Here is the customer :\n");
printf("\t%s\tAcc#%i\n", customerNames[index], accountArray[index]);
system("pause");
bankerSide(accountArray, balanceArray, customerNames );
}
}