A pointer is also a variable that is used to store an address.
Variables can be manipulated indirectly,
The null NULL address and 0 are equivalent
Can point to any address during program execution
The naming convention for pointer variables is the same as the naming conventions for other variables
Pointer cannot have the same name as an existing variable
The pointer holds the address of any basic data type, array, and all other high-level structures in the C language
If the pointer is declared as an address pointing to a type of data, it cannot be used to store addresses of other types of data
You should specify an address for the pointer before you can use the pointer in the statement
A pointer is a variable that can change its value during the execution of a program, which can change the pointer's direction. You can point to the variable x at some point, or you can point to the variable y at another time
The harm of the pointer uninitialized;
Initialization refers to the definition and assignment of a value
#include <stdio.h>
int main ()
{
int *pa;//Wild pointer
printf ("pa=%p\n", PA);
printf ("*pa=%d\n", *PA);
Segment error: illegal memory was manipulated
*pa+=10;
return 0;
}
A pointer variable occupies a memory address that is 4 bytes
The operation of pointers;
1. Pointers and pointers
#include <stdio.h>
int main ()
{
int a=12;
int b=34;
int *pa=&a;
int *pb=&b;
int C=PA+PB;
return 0;
}
~ 650) this.width=650; "Src=" "/>
Two addresses add no meaning error
converting int C=PA+PB to int C=PA-PB will not give an error. Because int C=PA-PB is a distance representing 2 addresses, it is meaningful.
2. The addition and subtraction of pointers and integers is the offset of the address
Offset =n*sizeof (type)
&arr : The first address of the entire array offset 5*sizeof (int)
&arr+1 VS & (arr+1)
& (arr+1) is not valid, cannot take address of address
Equivalence between pointers and arrays
If the int *p=arr
PA equivalent to &arr[i]
*PA equivalent to arr[0]
int *PA store int or int[]
Embedded C-language pointers with notes