1. ## Structs

Hi , could anyone instruct me how could I look at members of struct members? I mean if I have variable length as integer like int length , so it's easy to just write length , but if that variable is a struct member , lets assume that struct called A, then in order to get the length we say A.length and not just write length .. my problem is that Im not finding it easy to write A.length instead of length, so anyone have a good approach to tell me how could I look at member inside the struct in order to be comfortable with the syntax once I write A.length and not length .

Exactly what happened that once I write A.length I say that It's not just a simple variable like length ..so that's why Im not finding it comfortable with because I have A. which still not make sense/sound for me.

thanks for helpers. 2. The Teir family has a few members. One of the members is named Brian. So, to differentiate him from a person named Brian from another family, or with no family name, we call him Brian Teir.

Do you find this to be a particularly difficult concept, Brian Teir? If not, A.length should be just as easy. 3. Originally Posted by laserlight The Teir family has a few members. One of the members is named Brian. So, to differentiate him from a person named Brian from another family, or with no family name, we call him Brian Teir.

Do you find this to be a particularly difficult concept, Brian Teir? If not, A.length should be just as easy.
Youre awesome, so if I understand you I could assume that I have variable called Brian Teir? so in the same concept I have variable called A.length which it's length but the variable called A.length and not length ..... am I right?

thanks alot 4. Originally Posted by Brian_Teir I have variable called A.length which it's length but the variable called A.length and not length ..... am I right?  5. Originally Posted by john.c  I mean that variable length is in concept LENGTH , so in the same manner I could assume that variable A.length is like variable length which it's conceptually LENGTH . 6. Are you equally confused about arrays?

Let's say you wanted to store the dimensions of a box using an array.
Code:
```int mybox;

Which looks like this laid out in memory.
+----------+
| mybox |
+----------+
| mybox |
+----------+
| mybox |
+----------+```
Now set some sizes for our box.
Code:
```// To keep our sanity, we assign specific indices of the array to be for a
// particular purpose, so we give each one a name.
#define LENGTH_INDEX 0
#define WIDTH_INDEX  1
#define HEIGHT_INDEX 2

mybox[LENGTH_INDEX] = 22;
mybox[WIDTH_INDEX]  = 33;
mybox[HEIGHT_INDEX] = 44;```
Now do the same thing with a struct.
Code:
```struct box {
int length;
int width;
int height;
};

struct box mybox;
Which looks like this laid out in memory.
+--------+
| length |
+--------+
| width  |
+--------+
| height |
+--------+```
See the similarity?

Now set some sizes for our box.
Code:
```mybox.length = 22;
mybox.width  = 33;
mybox.height = 44;```

So the thing we call a length, in the thing we call a box has been written as either
mybox[LENGTH_INDEX] = 22;
or
mybox.length = 22; 7. Originally Posted by Salem Are you equally confused about arrays?

Let's say you wanted to store the dimensions of a box using an array.
Code:
```int mybox;

Which looks like this laid out in memory.
+----------+
| mybox |
+----------+
| mybox |
+----------+
| mybox |
+----------+```
Now set some sizes for our box.
Code:
```// To keep our sanity, we assign specific indices of the array to be for a
// particular purpose, so we give each one a name.
#define LENGTH_INDEX 0
#define WIDTH_INDEX  1
#define HEIGHT_INDEX 2

mybox[LENGTH_INDEX] = 22;
mybox[WIDTH_INDEX]  = 33;
mybox[HEIGHT_INDEX] = 44;```
Now do the same thing with a struct.
Code:
```struct box {
int length;
int width;
int height;
};

struct box mybox;
Which looks like this laid out in memory.
+--------+
| length |
+--------+
| width  |
+--------+
| height |
+--------+```
See the similarity?

Now set some sizes for our box.
Code:
```mybox.length = 22;
mybox.width  = 33;
mybox.height = 44;```

So the thing we call a length, in the thing we call a box has been written as either
mybox[LENGTH_INDEX] = 22;
or
mybox.length = 22;

thanks got it, appreciated. Popular pages Recent additions a.length, length, struct, variable, write 