};
int find_part(int number, const struct part inv[], int np); void insert(struct part inv[], int *np);
void search(const struct part inv[], int np);
void update(struct part inv[], int np);
void print(const struct part inv[], int np);
/********************************************************** * main: Prompts the user to enter an operation code, * * then calls a function to perform the requested * * action. Repeats until the user enters the * * command 'q'. Prints an error message if the user * * enters an illegal code. * **********************************************************/ int main(void)
{
char code;
struct part inventory[MAX_PARTS];
int num_parts = 0;
for (;;) {
printf("Enter operation code: ");
scanf(" %c", &code);
while (getchar() != '\n') /* skips to end of line */ ;
switch (code) {
case 'i': insert(inventory, &num_parts);
break;
case 's': search(inventory, num_parts);
break;
case 'u': update(inventory, num_parts);
break;
case 'p': print(inventory, num_parts);
break;
case 'q': return 0;
default: printf("Illegal code\n");
}
printf("\n");
}
}
/********************************************************** * find_part: Looks up a part number in the inv array. *
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库C语言程序设计现代方法第16章答案(5)在线全文阅读。
相关推荐: