knowledge-database (beta)

Current group: comp.sources.d

Multi-dimensional array initialization

Multi-dimensional array initialization  
masood.iqbal at lycos.com
 Re: Multi-dimensional array initialization  
CBFalconer
 Re: Multi-dimensional array initialization  
masood.iqbal at lycos.com
 Re: Multi-dimensional array initialization  
CBFalconer
From:masood.iqbal at lycos.com
Subject:Multi-dimensional array initialization
Date:23 Jan 2005 02:13:03 -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);
}
From:CBFalconer
Subject:Re: Multi-dimensional array initialization
Date:Sun, 23 Jan 2005 10:47:07 GMT
masood.iqbal@lycos.com wrote:
>
> 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:

Three copies of this malformed posting in less than 100 minutes! I
suggest you find a newsreader, or a way of using google to make
readable posts, with indentation and line lengths limited to 72
(better 65) chars.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
From:masood.iqbal at lycos.com
Subject:Re: Multi-dimensional array initialization
Date:23 Jan 2005 06:01:07 -0800
First of all my apologies for the multiple postings. It was certainly
not intentional. Actually the google news-server kept giving me an
error message to the following effect (paraphrasing here):

Due to a temporary server error the message could not be posted.
Kindly try again in 30 seconds.

I actually waited for about a minute or so each time before reposting.
I kept getting this error, and I kept retrying. It now appears to me
that those were spurious error messages. I will be more careful in
future (and just ignore this error message).

It may a partial consolation that I have already removed the extra
copies of my postings.
From:CBFalconer
Subject:Re: Multi-dimensional array initialization
Date:Sun, 23 Jan 2005 17:07:42 GMT
masood.iqbal@lycos.com wrote:
>
.... snip ...
>
> It may a partial consolation that I have already removed the extra
> copies of my postings.

FYI you cannot remove your postings, no matter what your system
tells you. They are distributed to many thousands of systems
implementing usenet, most of which do not heed any cancel messages
(due to misuse by imbeciles). Don't be misled by the idea that
Google is the medium, it is actually a very small part of it. All
those extra copies of your original are still residing on my
system, and on my ISPs system, and many many other places.

Meanwhile, listen to Eric Sosman.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
   

Copyright © 2006 knowledge-database   -   All rights reserved