Home > other >  A one-dimensional array and what is the difference between the memory layout of two-dimensional arra
A one-dimensional array and what is the difference between the memory layout of two-dimensional arra

Time:11-02

The array is not straight?
Discontinuous or two-dimensional array of address?

CodePudding user response:

According to which a one-dimensional array will cause difference
That is [a, b] after put a + 1, b] or [a, b + 1] is certainly different

CodePudding user response:

Two-dimensional array, you will "line" as an element, the two dimensional array is "the array",

Actually, you declare a pointer, to visit the space, the array will see.

CodePudding user response:

https://wenku.baidu.com/view/f6bbb441e45c3b3567ec8bda.html

CodePudding user response:

Array of memory continuously, whether a few dimension, then see how LZ you visit: line & amp; The column,

CodePudding user response:

Defines a two dimensional array
Each address output

CodePudding user response:

There is a difference in simple terms, memory, two-dimensional one dimensional array can also you use to access

CodePudding user response:

This article speak perfectly:
Main page or memory exchange will affect the efficiency of access
http://blog.sina.com.cn/s/blog_446b43c10100d6e6.html

CodePudding user response:

Don't regardless of paging (STM as) any data into squares, placement, is continuous, you can even directly as is a fact that there is a one dimensional array, the so-called 2 d is even higher, this is only the difference between array index method, a two dimensional array, 4 * 5 just for 20 consecutive address in memory, and a 1 * 20 one-dimensional array is not any difference, you can use the pointer access to test can fully understand,

CodePudding user response:

refer to the eighth floor tianxj001 response:
does not consider the paging (STM as if don't have to) any data into blocks, placed, are straight, you can even directly as is a fact that there is a one dimensional array, the 2 d is even higher, this is only the difference between array index method, a two dimensional array, 4 * 5 just for 20 consecutive address in memory, and a 1 * 20 one-dimensional array is not any difference, you can use to access to test can fully understand that

Yes, I use to access the, is indeed a straight! The problem is when I interview, the interviewer asked me the topic, said char [1024] and char [32] [32] what's the difference between a memory layout?

CodePudding user response:

There's a difference, big difference

CodePudding user response:

The
references to the tenth floor qq_26841367 response:
there's a difference, big difference between


What's the difference, please help solve it

CodePudding user response:

First said the first array, the definition of array data type is the same data for storing a data structure, so whether one dimension or a few dimensional array, once defined, are in continuous stored in physical space, moreover, the data is stored in a one-dimensional array of the same size if you need more memory pages stored, so in the case of the data stored in a multidimensional array is also occupy the same number of pages, no matter no paging, these addresses are continuous,
A one-dimensional array and two-dimensional array is different place, an array of row pointer, two-dimensional array row pointer, through the row pointer can be more quick and intuitive to read and write data, this is a two-dimensional array than one-dimensional array convenient place,
  • Related