knowledge-database (beta)

Current group: comp.sources.d

Multi-dimensional array initialization

Multi-dimensional array initialization  
masood.iqbal at lycos.com
From:masood.iqbal at lycos.com
Subject:Multi-dimensional array initialization
Date:23 Jan 2005 01:10:53 -0800
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);
}
   

Copyright © 2006 knowledge-database   -   All rights reserved