如何在C中构建以下类型的数组?
arr = [['S', 'NP+NP', 'S'],['S', 'NP+NUMBER', 'VP+VERB'],['S', 'VERB', 'NP']]
答案 0 :(得分:3)
char const* arr[][3] = {{"S", "NP+NP", "S"}, {"S", "NP+NUMBER", "VP+VERB"}, {"S", "VERB", "NP"}};
答案 1 :(得分:0)
const char *strs[] = {"foo", "bar", "bletch", ...};
你可以像这样访问它们
for(int i = 0; i < NUMBER_OF_STRINGS; i++) {
printf("%d: %s\n", i, strs[i]);
}