当前位置:网站首页>C写菜单指令的快捷方法
C写菜单指令的快捷方法
2022-08-09 14:53:00 【黄小鸭233】
从老师那学到的写菜单指令的方法,可以不用再switch,case一条一条打过去了
//***********写菜单指令的方法*********
//typedef struct SeqTable* ST;
typedef void (*FUNC)(ST); //函数指针,内部的函数参数都为ST类型
struct
{
const char* desc;
FUNC func;
}acts[] =
{
{"退出(销毁)", destroy},
{"显示顺序表属性", show}, //是否为空 是否满了 元素个数 容量 ...
{"在末尾插入", push},
{"在指定位置插入", insert},
{"在末尾删除", pop},
{"删除指定位置元素", my_remove},
{"删除指定元素", delete},
{"更新", update},
{"根据元素值查找", find},
{"根据条件查找", search},
{"统计", count},
{"清空", clear}
};
void menu(void)
{
puts("******测试******");
int i;
for(int i = 0; i < sizeof(acts)/sizeof(acts[0]); i++)
printf("***%d.%s\n", i, acts[i].desc);
printf(">>>");
}
void test_seqtable(void)
{
ST st = create_sqrtable(10);
while(true)
{
menu();
int in = 0;
scanf("%d", &in);
if(in >= 0 && in < sizeof(acts)/sizeof(acts[0]))
acts[in].func(st);
else
printf("Error!\n");
}
}
//*******************************************写函数就类似这种
void clear(ST st)
{
clear_seqtable(st);
show(st);
}边栏推荐
猜你喜欢
随机推荐
经典面试题 之 TCP 三次握手/ 四次挥手
对程序化交易系统接口有什么误区?
Analysis: Which method is used to build a stock quantitative trading database?
focal loss原理及简单代码实现
英语议论文读写01 Business and Economics
What are the misunderstandings about the programmatic trading system interface?
复数与复数域
经典面试题 之 JVM调优
经典面试题 之 SQL优化
常见的数学物理方程
docke安装mysql以及主从搭建(并且指定数据生成路径)
Mysql两个引擎对比
编译器不同,模式不同,对结果的影响
LNK1123:转换到COFF期间失败:文件无效或损坏
redis6在centos7的安装
How to flexibly use the advantages of the quantitative trading interface to complement each other?
Talking about quantitative trading and programmatic trading
docker安装单机版redis、集群版redis
What do professional quantitative traders think about quantitative trading?
如何通过股票量化交易接口实现盈利稳定?

![[MySql] implement multi-table query - one-to-one, one-to-many](/img/7e/8f1af4422a394969b28a553ead2c42.png)






