-
int *a defines a pointer variable. a is a pointer variable that points to an int variable, called an int pointer. * indicates the type of pointer. The pointer variable name is a instead of *a.
int a array.
a The name of the array is the address of the first array element, which is the same as the first address of the array, which is easy to understand.
a represents the first address of the array, which is the same as the above number, but has a different meaning.
In memory, A+1 is the next element.
A+1 is an array.
-
Array names only have meaning in the source **, so they only make sense in the source environment or at compile time (only the address in the compiled executable program), at this time, the compiler will create a mapping table "identifier-address" for all data entities, including variables, arrays, objects, structures, and function bodies, so that they can be converted to addresses when a variable is encountered, and at the same time, it is convenient to debug the trace.
These tables and other extra data are included in the target program as debug parameters if compiled in debug mode, while this information is not included if compiled to a release version.
So from a compilation point of view, any variable name is a pointer, so the pointer array name is of course also a pointer, and the simplest int a, the "a" itself is a pointer. When accessing any variable, the compiler arranges for the address to be taken first, and then decides whether to take the value further based on the variable type, i.e., an implicit conversion.
For example, when accessing a common variable, the compiler's default operation is to take the value, so when int b=a, it takes the addresses of a and b first, and then writes the value of a into the memory of b, if you want to get the address of a, you need to explicitly convert int *p=&a;, so that the compiler takes the address of a and assigns it directly to p, without further operation. And if a is an array, we encounter int *p=a; After the compiler takes the address, it directly assigns a value to p without further operation.
Summary: 1. Data entities: all variables, arrays, objects, structures, and linked lists in the source. . . Function body, all accessible resources.
2. Any data entity has an address.
3. When the compiler accesses the data entity, it must first locate it, that is, it must obtain the address.
4. The values of ordinary variables and the addresses of arrays are implicit conversions designed by the compiler.
-
These concepts are inseparable from RAM, so let's talk about memory first.
The memory is like a building, there are many, many small rooms in it, and each room has a house number, which is the address. The function of the address is to find the corresponding room by this house number.
The pointer is to put an address in multiple rooms (this thing is very large, it takes many rooms to fit Sensheng), and you can find the target room (memory) by getting the place where you put it through the pointer.
The array means that I need a contiguous room that can put n addresses or values (the reference type stores the address, and the value type directly stores the value), and the variable of the array name stores the address of the first spring band of these consecutive rooms.
Pure hand hit, thank you.
-
Friends rotten answer]: a, c
An array pointer is just a pointer variable that occupies the storage space of a pointer in memory, while a pointer array is a number of silver pointer variables that exist in memory in the form of an array and occupy the storage space of multiple pointers.
Array of pointers. First of all, it is an array, the elements of the array are all pointers, and the number of bytes occupied by the array is determined by the array itself. It is short for "array of stored pointers". >>>More
int a =;
int b =; >>>More
2D array address - > row address - > column address (variable address) - > variable value, or excerpt a description for you. >>>More
There is no difference between a string and an array of characters. >>>More
Arrays are not allowed to add values to them, you can put them in a list. >>>More