我正在try 确定是否可以执行以下操作,但不必声明各个变量……
static char *set_list1[] = { "set", "one", NULL };
static char *set_list2[] = { "set", "one", "negative", NULL };
static char *set_list3[] = { "set", NULL };
static char *set_list4[] = { "set", "one", "new", "item", "here", NULL };
static char **set_list[] = { set_list1, set_list2, set_list3, set_list4, NULL };
基本上,我需要一个指针数组,然后每个指针指向一个可变长度的字符串数组(恰好以空指针结束.
显然,我可以像上面那样声明它,但有没有一种方法可以做到这一点,而不必声明每个名称呢?
直觉上,这感觉应该行得通,但没有...
static char **my_array[] = {
{ "one", "two", NULL },
{ "another", NULL },
{ "more", "items", "here", NULL },
NULL
};
感谢任何帮助