 | Hi,
I have seen at least two ways to initialize multi-dimensional arrays in C. One of the ways is shown in a sample code snippet below. The other way does not make use of any intermediate braces. In other words, all the entries are listed under the same pair of enclosing braces. For example:
char* mdTbl[3][5] = { "One", "Two", "Three", "Four","Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen" };
Are the two approaches exactly identical, or is there any difference between them?
Thanks, Masood /****************************************************** ******************************************************/
#include
char* mdTbl[3][5] = { { "One", "Two", "Three", "Four", "Five" }, { "Six", "Seven", "Eight", "Nine", "Ten" }, { "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen" }, };
void print_array_element(int row, int column) { printf("%s\n", mdTbl[row][column]); }
main() { print_array_element(2, 2); }
|
|