Hi guys, I've read over the internet about structs in C and what's confusing me is:
lets assume I have a struct like this:
what's actually the address of b1 look/visualize in the memory? b1 is a struct with properties of name and size ..
is it like thisassuming the address of b1 is 1234)
?
I'm asking like this question because for example in type of int once we write int x, the first byte's address of 4 bytes(because it's int) is assigned to x, meaning lets assume the addresses of 4 bytes of int like this: 1 2 3 4 which all storing the data of x, so the address of x is 1 because it's by default the pc assigning the first address of the first block of 4 bytes to x.
what about the address of b1? is the pc assigning it to the address of the first property that we build in the struct(in my case &b1 is the same address of size) ?
secondly, in programming we most using names(variables) for expressing about memory location, which means there might be for instance memory location of 6 bytes which referred to specific name, but how actually 6 bytes entering that specific name? means 6 bytes having alot of addresses on it so how actually that specific name(variable) storing them all in one hit? to clear more, specific name (variable) at the end will have one "address" that can be stored in it, but 6 bytes having multiple addresses, so how that specific name storing them all in one hit? in other words, I'm not understanding or succeeding to visualize how several blocks of memory location are stored as one complement in a specific name?! it's look like several blocks of memory location converted to one complement block to be stored in a specific name which its entity space of storing is one block(not several blocks)... looks like several blocks compressed to one block with specific name ..
thanks guys alot
lets assume I have a struct like this:
Code:
struct Book
{
int size;
char name[20];
}
Book b1;
is it like thisassuming the address of b1 is 1234)
Code:
1234: b1
5678: name
5699: size
I'm asking like this question because for example in type of int once we write int x, the first byte's address of 4 bytes(because it's int) is assigned to x, meaning lets assume the addresses of 4 bytes of int like this: 1 2 3 4 which all storing the data of x, so the address of x is 1 because it's by default the pc assigning the first address of the first block of 4 bytes to x.
what about the address of b1? is the pc assigning it to the address of the first property that we build in the struct(in my case &b1 is the same address of size) ?
secondly, in programming we most using names(variables) for expressing about memory location, which means there might be for instance memory location of 6 bytes which referred to specific name, but how actually 6 bytes entering that specific name? means 6 bytes having alot of addresses on it so how actually that specific name(variable) storing them all in one hit? to clear more, specific name (variable) at the end will have one "address" that can be stored in it, but 6 bytes having multiple addresses, so how that specific name storing them all in one hit? in other words, I'm not understanding or succeeding to visualize how several blocks of memory location are stored as one complement in a specific name?! it's look like several blocks of memory location converted to one complement block to be stored in a specific name which its entity space of storing is one block(not several blocks)... looks like several blocks compressed to one block with specific name ..
thanks guys alot