Hi,
I think check for locate_part function in add() should be
if (locate_part(name) >= 0) {
printf("Part is already in database.\n");
return; }
As per the code u may be able to add the same string which locate enters first into the database.
You missed check for 0th index.
insted of
if (locate_part(name) > 0)
use
if (locate_part(name) >= 0)
AWESOME! I knew there was a logic error somewhere, props to you for finding it because I sure couldn't.
And for the last problem, and then I will have a 99% complete project. I need to be able to sort the the structure by it's members (forgive me if me terminology is wrong). Right now, this code will just print the members in the order they were saved.
void part (void){
int i;
printf("\n");
for(i=0; i<num_parts; i++)
printf("%s:%s:%s:%s:%s\n", parts[i].name, parts[i].owner, parts[i].status, parts[i].date, parts[i].renter);
}
So if this code prints:
Hook : Mike : Out : 02/30/2008 : Mark
Axel : Tim : in : :
and I need to print it sorted by the member parts.name so it prints like this:
Axel : Tim : in : :
Hook : Mike : Out : 02/30/2008 : Mark
how can I accomplish this? From what I have seen there is no simple sort function for structures, so am I going to have to write a function to sort it? If so, what's the logic behind it?