| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 605 人关注过本帖
标题:[求助]ESC 的問題
只看楼主 加入收藏
cjw23529
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2007-3-22
收藏
 问题点数:0 回复次数:1 
[求助]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);
}





IZDKeKSF.txt (1.02 KB) [求助]ESC 的問題

搜索更多相关主题的帖子: ESC 
2007-03-30 06:16
cheng111111
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-4-1
收藏
得分:0 
case 27: 那一段修改以下:
case 4:
printf("bye\n");
return;

break;
2007-04-03 14:34
快速回复:[求助]ESC 的問題
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017454 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved