c - 使用字符串数组引用结构成员?
问题描述
我有一些来自 Matlab/Simulink 的自动生成的 c 代码,其中包含参数值的结构,其中成员是它们自己的参数名称。像这样的东西
Param.ParameterName1 = 5;
Param.ParameterName2 = 10;
然后我有一个ParameterList
包含参数名称的字符串 () 数组。我想做的是使用参数名称ParameterList
来引用结构的成员,这样我就可以为参数分配新值。像这样的东西:
i = 1;
Param.ParameterList[i] = 10;
这甚至可能吗?还有其他方法可以解决这个问题吗?
谢谢。
解决方案
推荐阅读
- javascript - 为什么我的“EventListener”函数只执行一次?
- python - Python(django)同时调用两个管理命令
- c - CAN 总线 - 无法读取
- python - 带有 API 调用的 Pytest 烧瓶视图 - 连接被拒绝
- keras - “你的输入用完了数据”总是在第 # 步
- mysql - 如何从具有当前日期的表中选择值
- angular - FormControl ValueChanges 管道未触发
- javascript - 如何在 JavaScript 循环中合并两个数组
- sql-server - T-SQL 查询挂起
- python - 如何从 Python 中的二级 Json 键中获取值