我有以下用于德语动词练习的代码块:
if (strcmp(*option, "sein") == 0)
*option = linie.sein;
if (strcmp(*option, "haben") == 0)
*option = linie.haben;
if (strcmp(*option, "possessiv") == 0)
*option = linie.possessiv;
if (strcmp(*option, "reflexiv") == 0)
*option = linie.reflexiv;
if (strcmp(*option, "accusativ") == 0)
*option = linie.accusativ;
if (strcmp(*option, "dativ") == 0)
*option = linie.dativ;
但是,我想将其浓缩为:
*option = linie.(*option);
也许:
*option = linie.(*option)();
不幸的是,这些都不起作用。有任何想法吗?
编辑@dasblinkenlight:
typedef struct
{
char subjekt[20];
char sein[20];
char haben[20];
char possessiv[20];
char reflexiv[20];
char accusativ[20];
char dativ[20];
} satz;
satz linie =
{
.subjekt = "",
.sein = "",
.haben = "",
.possessiv = "",
.reflexiv = "",
.accusativ = "",
.dativ = ""
};
char *option = argv[1];