如何在C中构建字符串数组

时间:2014-06-05 04:53:27

标签: c arrays string

如何在C中构建以下类型的数组?

arr = [['S', 'NP+NP', 'S'],['S', 'NP+NUMBER', 'VP+VERB'],['S', 'VERB', 'NP']]

2 个答案:

答案 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]);
    }