How is memory allocated for an implicitly defined multidimensional array in C99?

后端 未结 4 1771
耶瑟儿~
耶瑟儿~ 2020-12-11 12:02

I\'m trying to write a C99 program and I have an array of strings implicitly defined as such:

char *stuff[] = {\"hello\",\"pie\",\"deadbeef\"};
4条回答
  •  自闭症患者
    2020-12-11 12:25

    In the first example, it is a jagged array I suppose.

    It declares an array of const pointers to a char. So the string literal can be as long as you like. The length of the string is independent of the array columns.

    In the second one.. the number of characters per row (string) lengths must be 9 as specified by your column size, or less.

提交回复
热议问题