ok guys, im looking to use a linear search to search a structure for a certain account number. the structure is as follows.
Code:
typedef struct {
int acctNum;
char lastName[ 15 ];
char firstName[ 10 ];
double balance;
} clientData;
i have called the function containing the linear search however my actual search algorithm for this wrong. a linear search on a normal array is much easier and im finding troubles determining how to complete the search. this is what i have.
calling funtion using a previously found search key.
Code:
element = linearSearch (customer, searchKey, SIZE)
then this is my function for the linear search.
[code]
int linearSearch ( clientData client [], int Key, int arrsize){
int n;
for ( n = 0; n <= arrsize - 1; n++ )
if (strcmp (client[n] .acctNum, Key) == 0)
return n;
return -1;
}
can anyone advise me of how to alter this linear search algorithm so that is searches for an account number that is requested?