当前位置:网站首页>A shortcut method for writing menu commands in C
A shortcut method for writing menu commands in C
2022-08-09 16:19:00 【Yellow ducklings 233】
The method of writing menu commands that I learned from the teacher can no longer be switched, and the case is typed one by one
//***********How to write menu commands*********//typedef struct SeqTable* ST;typedef void (*FUNC)(ST); //Function pointer, the internal function parameters are ST typestruct{const char* desc;FUNC func;}acts[] ={{"Exit (destroy)", destroy},{"Display sequence table property", show}, //Whether it is empty or not, whether it is full, the number of elements, the capacity ...{"Insert at the end", push},{"Insert at the specified position", insert},{"delete at the end", pop},{"Remove the element at the specified position", my_remove},{"Delete the specified element", delete},{"update", update},{"Search by element value", find},{"Search by condition", search},{"statistics", count},{"clear", clear}};void menu(void){puts("******test******");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);elseprintf("Error!\n");}}//********************************************Write a function like this
void clear(ST st){clear_seqtable(st);show(st);}边栏推荐
- In the process of quantitative trading, retail investors can do this
- 【C语言初阶】倒置字符串(输入 I like beijing. 输出beijing. like I)
- 如何灵活运用量化交易接口的优势取长补短?
- What are the implications of programmatic trading rules for the entire trading system?
- MySQL学习笔记
- How to flexibly use the advantages of the quantitative trading interface to complement each other?
- focal loss原理及简单代码实现
- Mathematica 作图详解
- Suddenly want to analyze the mortgage interest rate and interest calculation
- 内存泄露检测工具VLD(Visual Leak Detector)使用说明
猜你喜欢
随机推荐
How do quantitative investors obtain real-time market data?
C language operator precedence
如何保证电脑硬盘格式化后数据不能被恢复?
What drives the development of quantitative trading interfaces?
How to achieve stable profit through the stock quantitative trading interface?
docke安装mysql以及主从搭建(并且指定数据生成路径)
The difference between show and exec in Qt dialog
What do professional quantitative traders think about quantitative trading?
数组学习笔记
怎么用VS+Qt创建新项目
大咖说·对话生态|当Confluent遇见云:实时流动的数据更有价值
6大论坛,30+技术干货议题,2022首届阿里巴巴开源开放周来了!
内存泄露检测工具VLD(Visual Leak Detector)使用说明
文件操作的实例——下载并合并流式视频文件
NetCore 5.0连接MySql
爱因斯坦的光子理论
贝塞尔函数
redis6在centos7的安装
小型项目如何使用异步任务管理器实现不同业务间的解耦
数据库多表链接查询的方式









