I'm wondering if the arrays a[]
and b[]
in the code below are contiguous in memory:
int main() {
int a[3];
int b[3];
return 0;
}
a[0]
,a[1]
and a[2]
should be contiguous and the same for b
, but are there any guarantees on where b
will be allocated in relation to a
?
If not, is there any way to force a
and b
to be contiguous with eachother? i.e. - so that they are allocated next to eachother in the stack.
a
andb
to be contiguous you could put them in a struct. Even then you will have to contend with details such as padding. – Jillianjillie