[求助]ESC 的問題
各位大大 我差不多把這個程序給完善了但我有個問題就是我無法案'ESC'跳出程序
我用了 case 27;
還有 while (selection != 27);
都不行 麻煩大大幫我看看哪裡出錯了 謝謝
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
int quantity;
char compenent_type[20];
char compenent_value[20];
}parts_record;
void getInput( parts_record *ptr_parts);
void Display( parts_record *ptr_parts);
int main(int argc, char *argv[])
{
parts_record record[50];
char selection;
int i,j,k;
i = 0;
do
{
printf("Welcome to the component record market\n\n");
printf("Press 1 to add a record.\n");
printf("Press 2 to delete a record.\n");
printf("Press 3 to view all records.\n");
printf("Press 'ESC' to exit.\n\n");
printf("Your selection is ");
scanf(" %d", &selection);
printf("\n");
switch( selection )
{
case 1:
printf("record number:[%d]\n",i+1);
getInput(&record[i]);
i++;
continue;
case 2:
printf("Which record you want to delete:");
scanf("%d",&j);
for(k=j-1;k<i;k++)
memcpy(&record[k],&record[k+1],sizeof(parts_record));
i--;
continue;
case 3:
j = 0;
for (j=0; j<i; j++)
{
printf("record:[%d]\n",j+1);
Display(&record[j]);
}
continue;
case 27:
printf("Bye.\n\n");
break;
default:
printf("Your selection is not valid.\n");
printf("Please try again\n");
printf("\n");
}
}while (selection != 27);
system("PAUSE");
return 0;
}
void getInput( parts_record *ptr_parts)
{
printf("Name of compenent type:");
fflush(stdin);
scanf("%s",ptr_parts->compenent_type);
printf("The value of component:");
fflush(stdin);
scanf("%s",ptr_parts->compenent_value);
printf("How many in the stock: ");
scanf(" %d", &ptr_parts->quantity);
}
void Display(parts_record *ptr_parts)
{
printf("compenent type: %s\n", ptr_parts->compenent_type);
printf("The value of component: %s\n", ptr_parts->compenent_value);
printf("Quantity in stock: %d\n\n", ptr_parts->quantity);
}