1. Definition of pointers
Format: Variable type * variable name;
1: //defines a pointer variable p
2: //pointer variable can only store address
3: //Pointer is a function: can access the corresponding storage space according to an address value
4: //pointer variable p before INT: pointer variable p can only point to data of type int
5:
6: int *p;
2. Pointers pointing to pointers
3. Pointers and Arrays
1) How array elements are accessed int ages[5];int *p;p = ages;1> array name [subscript] ages[i]2> pointer variable name [subscript] p[i]3> * (P + i) 2) pointer variable +1, address value exactly how much, depending on the type of pointer int * 4 char * 1 double * 8
4. Point of attention of the pointer
1
1: /* Not recommended notation, int *p can only point to data of type int
2: int *p;
3: Double d = 10.0;
4: p = &d;*/
2
1: / * Pointer variable can only store address
2: int *p;
3: p = $;
4: * /
3
/* Pointer variable is not initialized, do not use indirect access to other storage spaces
int *p;
printf ("%d\n", *p);
*/
4
When defining a variable, the * is only a symbol, no other special meaning
int *p = &a;
5
Incorrect wording
*p = &a;
p = &a;
6
The function of this time: access to the storage space pointed to by the variable p
*p = 20;
Dark Horse programmer--"Dark Horse video Note"--pointer to C language Foundation