};
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. *