/********************************************************** * search: Prompts the user to enter a part number, then * * looks up the part in the inv array. If the * * part exists, prints the name and quantity on * * hand; if not, prints an error message. * **********************************************************/ void search(const struct part inv[], int np)
{
int i, number;
printf("Enter part number: ");
scanf("%d", &number);
i = find_part(number, inv, np);
if (i >= 0) {
printf("Part name: %s\n", inv[i].name);
printf("Quantity on hand: %d\n", inv[i].on_hand); } else
printf("Part not found.\n");
}
/********************************************************** * update: Prompts the user to enter a part number. * * Prints an error message if the part can't be * * found in the inv array; otherwise, prompts the * * user to enter change in quantity on hand and * * updates the array. * **********************************************************/ void update(struct part inv[], int np)
{
int i, number, change;
printf("Enter part number: ");
scanf("%d", &number);
i = find_part(number, inv, np);
if (i >= 0) {
printf("Enter change in quantity on hand: ");
scanf("%d", &change);
inv[i].on_hand += change;
} else
printf("Part not found.\n");
}
/********************************************************** * print: Prints a listing of all parts in the inv array, *