Suppose I have the following array:
int list[3]={2,8,9};
printf(\"%p,%p,%p\",(void*)&list[0],(void*)&list[1],(void*)&list[2]);
Is i
If you are asking about how memory appears inside the C model, then arrays appear to be contiguous in C code, and the C expression &list[0] < &list[1]
is true.
If you are asking about how actual memory appears inside a C implementation, the C standard does not require any particular arrangement of arrays in memory. Most C implementations use consecutive ascending virtual memory for arrays, but descending addresses would be a simple variation. And, at the level of physical memory, arrays are not generally consecutive, because the map from virtual memory to physical memory is determined by the operating system based on whatever it has available and may even change during execution of a process.
Additionally, there is no guarantee that the strings printed by %p
are memory addresses.