Dark Horse programmer------<a href= "http://www.itheima.com" target= "blank" >java training, Android training, iOS training,. NET training </a>, look forward to communicating with you! -------
Four arrays and pointers
01 The array name represents the first address of the array in memory, which represents the address information, so the array name can be interpreted as a pointer, but the array name is a constant and cannot be changed.
#include <stdio.h>intMain () {Charname[]="haha"; Charname1[]="GGGG"; Charname3[2][Ten] = {"fffff","JJJJJ"}; printf ("%s\n", name3[0]); return 0;}
02 Pointers to arrays: Defining a pointer to an array is the assignment of the first address of the array to the pointer variable.
such as: int a[10];
int *p; p=&a[0];
P=&a[0] equivalent to P=a
#include <stdio.h>intMain () {Charname[]="haha"; Charname1[]="GGGG"; Charname3[2][Ten] = {"fffff","JJJJJ"}; printf ("%s\n", name3[0]); return 0;}
03 referencing an array element by pointer: P+i represents the address of a[i], * (P+i) represents the array element A[i]
04 You can change the value of a pointer variable, but the pointer constant cannot be changed. Pointer operators have the highest precedence
05 Multi-dimensional arrays and pointers:
X[i] equivalent to * (X+i)
&x[i] equivalent to X+i
/*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 Add how much, depending on the type of pointer int * 4 char * 1 double * 8*/#include<stdio.h>voidChangint*array);intMain () {intAges[] = {Ten,5, -, the, $}; Chang (ages); return 0; }voidChangint*Array) {printf ("%d\n", array[2]); }
06 pointer variables pointing to multidimensional array elements:
Pointer variables that point to a one-dimensional array consisting of M elements are defined as: type name (* pointer variable name) [length]; such as: Int (*PA) [4];
07 Strings and Pointers:
When accessing characters in a string, you can define a pointer variable, point to the first character in the string, and then use the pointer's movement to access the characters in the string
15-Dark Horse programmer------C Language Learning notes---arrays and pointers