declare and write array
Dec 4, 2013 at 11:56am UTC
I want to develop array w3 with dimensions 4*1(height*width) as below and write
a_1...._a4 in it. How could i write w3 with these? Pleae tell me the syntax.
1 2 3 4 5 6 7
unsigned int w3 [4][1];
unsigned int a_1 = 0x02;
unsigned int a_2 = 0xff;
unsigned int a_3 = 0x32;
unsigned int a_4 = 0x0f;
Dec 4, 2013 at 8:12pm UTC
Well, if the width is 1, the array has just a single dimension - unless you plan to change the design later, the [1] isn't needed.
unsigned int w3[4] = { 0x02, 0xff, 0x32, 0x0f };
Last edited on Dec 4, 2013 at 8:23pm UTC
Dec 5, 2013 at 9:09am UTC
Actually I want array of 4 rows and 1 column.
Is array of 4 rows and 1 column the same as 4*1(height*width)?
Dec 5, 2013 at 10:38am UTC
4*1 equals 4. 4 elements. A 1D array for 4 elements, like Chervil suggested.
There is no "right" in space.
Topic archived. No new replies allowed.