/********************************************************** * 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, *
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库C语言程序设计现代方法第16章答案(7)在线全文阅读。
相关推荐: