<> one , Character pointer

1. Two ways of writing character pointer
int main() { char ch = 'a'; char*pc = &ch; char*p = "abcdef"; // Add the first character a Put your address in p in
return 0; }
Address symbols can be used , You can also use double quotes with characters , there abcdef Is a constant string , It can't be changed .

<> two , Pointer array

In a nutshell , It's an array of pointers .
int main() { int *arr[10]; char*ch[20]; return 0; }
<> three , Array pointer

It's essentially a pointer
int main() { int a = 10; int *p = &a; char ch = 'w'; char*pc = &ch; int arr[10]
= { 0 }; int(*pa)[10] = &arr; //pa Is a pointer to an array //&arr The array name is the entire array , What we get is the address of the array return 0;
}
Application of array pointer
eg: Print 2D array
1. Array method
void print(int arr[3][5], int r, int c) { int i = 0; for (i = 0; i < r; i++) {
int j = 0; for (j = 0; j < c; j++) { printf("%d", arr[i][j]); printf("\n"); } }
} int main() { int arr[3][5] = { { 1, 2, 3, 4, 5, }, { 2, 3, 4, 5, 6 }, { 3, 4,
5, 6, 7 } }; printf(arr, 3, 5); return 0; }
2. The method of array pointer
void print(int (*p)[5],int r,int c) { int i = 0; for (i = 0; i < r; i++) { int
j= 0; for (j = 0; j < c; j++) { printf("%d ", *(*(p + i) + j)); } } } int main()
{ int arr[3][5] = { { 1, 2, 3, 4, 5, }, { 2, 3, 4, 5, 6 }, { 3, 4, 5, 6, 7 } };
// Two dimensional array parameter transfer , The array name is also the first element address , The first element of a two-dimensional array is the address of the first line // It's the address on the first line printf(arr, 3, 5); return 0; }
By analogy, we can transfer parameters from one-dimensional arrays , It's the first address , Pass to receive with one-dimensional pointer or array , Get a binary array to pass parameters , It's the address on the first line , Receive with array pointer .

Technology
©2020 ioDraw All rights reserved
SSM— User module ( two ) Forget the password , Change Password , Get user information One and a half years JAVA Summary of work experience python To solve the problem of dictionary writing list in Vue Common features ( Form operation ) Rare expletives in Lei Jun's press conference : this XXX I'm definitely here to make trouble !PYTHON Summary of final review 2021 Front end interview written questions and answers After the black myth Wukong Another domestic game blown up by foreigners 27 Year old invention SQL in the future , God took him away CLion Novice step on the pit :CMake project is not loaded