如何将字符串转换为变量名?我有一个字符串列表:
"str1", "str2", "str3", etc.
Run Code Online (Sandbox Code Playgroud)
和一个结构:
struct my_struct {
int str1;
int str2;
int str3;
} m = {5, 10, 15, ... etc};
Run Code Online (Sandbox Code Playgroud)
给定一个字符串"str2",我想打印与该名称相关的变量m.str2.C有什么办法吗?
谢谢!