C语言根据函数名调用对应的函数
2024-08-24 07:17:34
通过函数指针定义,调用时加上参数
struct Command {
const char *name;
const char *desc;
// return -1 to force monitor to exit
int (*func)(int argc, char** argv, struct Trapframe* tf);
};
static struct Command commands[] = {
{ "help", "Display this list of commands", mon_help },
{ "kerninfo", "Display information about the kernel", mon_kerninfo },
{ "backtrace", "Display the current stack trace", mon_backtrace },
};
if (strcmp(argv[0], commands[i].name) == 0)
return commands[i].func(argc, argv, tf);
最新文章
- 关于ScrollView嵌套ListView问题
- SQL Cumulative Sum累积求和
- HTML、CSS和JS
- 读写文本(.txt)文件 .NET
- mysql:批量更新
- HDU 4122
- OpenGL学习笔记之了解OpenGL
- 01---HTML整理
- Swift的闭包(一):闭包简介、闭包表达式的优化
- 大数据笔记01:大数据之Hadoop简介
- dubbo 服务化
- 关于LIST.Select().ToList()慢的问题
- 详细分析Java中断机制(转)
- Ubuntu 创建启动器
- LeetCode OJ 219.Contains Duplicate 2
- linux中grep命令的用法
- c++(选择排序)
- SpaceNet数据集
- springmvc 项目单元测试
- 建一个网站python