1.int *p = null and *p = NULL difference
int *p = NULL refers to the initialization of a pointer to null, with the specific procedure int *p; p = NULL.
The difference between 2.&a and a
int a[5];
int *p = &a; //??
int *q = A; //??
Is this code right?
Explain:
&a gets the address of the array.
A represents the first address of the first element of the array.
&a A is the same as the value of a, two points to the same location , but with a different meaning.
3. pointers and arrays of definitions and declarations
What are declarations and definitions:
An object in the C language must have only one definition, but it can have multiple extern declarations.
A definition is a special declaration that creates an object;
The statement simply describes the name created elsewhere, which allows you to use that name.
can only appear in one place |
example: |
Statement |
can appear multiple times |
Describes the type of object used to refer to objects defined elsewhere (for example, in other files). Example: extern int my_array[]; |
define the array, will open up space for it, and the array is the first element of the address, defined for the same content, with a different array representation, then the initial element of the address is not the same, because each definition of the array will open a space for it;
For the same content, pointing with a different pointer, the pointer variable is saved in the same address because there is a fixed position in memory for the content of the assignment to be fixed.
There are two special cases for the definition and declaration of arrays and pointers:
A. Define an array, declared as a pointer
B, defined as a pointer, declaring an array
If the concept of declarations and definitions is not very clear, it is easy to misuse both cases:
Define an array, declared as a pointer, the pointer can only access four bytes, 32 bit bit size, so when you want to access the array, you do not have the correct access to the contents of the array;
When you declare an array as a pointer, the array has access to the size of one of the arrays, and the pointer is only 4 bytes, so it is not possible to access the pointer's contents correctly when you want to access the pointer.
4. pointer and array comparison
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/76/7A/wKiom1ZUMI2iceKcAAFe_1H2bFg479.png "title=" Image.png "alt=" Wkiom1zumi2icekcaafe_1h2bfg479.png "/>
"C Language" "pointer-related knowledge summary"