Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.programming > #3841
| From | Todd Carnes <toddcarnes@gmail.com> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: Initializing Multi-dimensional Arrays in C |
| Date | 2011-02-03 14:25 -0500 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <iievgd$kb9$1@speranza.aioe.org> (permalink) |
| References | <iiejo7$lsk$1@speranza.aioe.org> <iiepca$544$1@news.eternal-september.org> |
On 02/03/2011 12:41 PM, James Waldby wrote:
> On Thu, 03 Feb 2011 11:05:15 -0500, Todd Carnes wrote:
> ...
>> double ag[3][3] =
>> {-0.0548755604, +0.4941094279, -0.8676661490,
>> -0.8734370902, -0.4448296300, -0.1980763734, -0.4838350155,
>> +0.7469822445, +0.4559837762};
>>
>> Warning I am getting:
>>
>> warning: missing braces around initializer (near initialization for
>> ag[0])
>>
>> Question: Will the following eliminate the warnings without breaking the
>> code?
>>
>> double ag[3][3] =
>> {{-0.0548755604, +0.4941094279, -0.8676661490},
>> {-0.8734370902, -0.4448296300, -0.1980763734},
>> {-0.4838350155, +0.7469822445, +0.4559837762}};
>
> That looks proper and will clear the 'missing braces' warnings.
> Also, since it will put the same data in the same places, it won't
> break anything new.
>
>> My problem is that I'm not sure how (in what order) the values are being
>> assigned in the first example. so, I'm not sure if my 'fix" will change
>> the order of assignment.
>
> In the above, both ag[][] have the same order. For more examples/advice, see eg
> <http://publib.boulder.ibm.com/infocenter/macxhelp/v6v81/index.jsp?topic=%2Fcom.ibm.vacpp6m.doc%2Flanguage%2Fref%2Fclrc03aryin.htm>
> and/or <http://msdn.microsoft.com/en-us/library/aa288453(v=vs.71).aspx>
>
>> P.S. I don't think it should matters, but just in case, I'm compiling on
>> linux.
>
> For c questions, it's more useful to state compiler name and version.
> Eg, quote first line of gcc --version output.
>
Thank you for your help.
The links look like they will be very useful. :)
For what it's worth gcc --version gives the following in my case...
gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
Todd
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar
Initializing Multi-dimensional Arrays in C Todd Carnes <toddcarnes@gmail.com> - 2011-02-03 11:05 -0500
Re: Initializing Multi-dimensional Arrays in C Todd Carnes <toddcarnes@gmail.com> - 2011-02-03 14:29 -0500
Re: Initializing Multi-dimensional Arrays in C "Pascal J. Bourguignon" <pjb@informatimago.com> - 2011-02-03 23:02 +0100
Re: Initializing Multi-dimensional Arrays in C Todd Carnes <toddcarnes@gmail.com> - 2011-02-03 14:25 -0500
Re: Initializing Multi-dimensional Arrays in C James Waldby <not@valid.invalid> - 2011-02-03 17:41 +0000
Re: Initializing Multi-dimensional Arrays in C "Pascal J. Bourguignon" <pjb@informatimago.com> - 2011-02-03 17:26 +0100
csiph-web