Array parameters are pointer parameters.
The pointer parameter is an immediate address parameter (or a reference parameter). If you want to modify the parameter value in the function, this is the only way.
If you treat an array as a parameter, whether you want it or not, it is a pointer pointing to the first value.
1. the array parameter is the pointer to the first element:
# Include <stdio. h> void getarr (int p [], int Si); int main (void) {int NS [] = {1, 2, 3, 4, 5}; getarr (NS, sizeof (NS)/sizeof (NS [0]); getchar (); Return 0;} void getarr (int p [], int Si) {int I; for (I = 0; I
2. simply declare it as a pointer:
# Include <stdio. h> void getarr (int * P, int Si); int main (void) {int NS [] = {1, 2, 3, 4, 5}; getarr (NS, sizeof (NS) /sizeof (NS [0]); getchar (); Return 0;} void getarr (int * P, int Si) {int I; for (I = 0; I
3. Even if you specify a dimension in the parameter:
# Include <stdio. h> void getarr (int p [2], int Si); int main (void) {int NS [] = {1, 2, 3, 4, 5}; getarr (NS, sizeof (NS)/sizeof (NS [0]); getchar (); Return 0;} void getarr (int p [2], int Si) {int I; for (I = 0; I
4. Since it is a pointer, its value may be modified:
# Include <stdio. h> void getarr (int p [], int Si); int main (void) {int NS [] = {1, 2, 3, 4, 5}; size_t I; getarr (NS, sizeof (NS)/sizeof (NS [0]); for (I = 0; I
5. If it is a character array, it can determine the end of the array:
# Include <stdio. h> void getarr (char P []); int main (void) {char NS [] = "abcdefg"; getarr (NS); getchar (); Return 0 ;} void getarr (char P []) {int I; for (I = 0; P [I]; I ++) {printf ("% C: % d \ n ", P [I], p [I]) ;}}