/* ============================================================================ name:testarray.c AUTHOR:LF Version:Copyright:Your Copyright Notice Description: Array is passed as an argument when an array is passed as a parameter because the copy of the array is a resource-intensive 1. To avoid In this case, the C language compiler passes an array of pointers when passing an array 2 c the array name represents the first address of the array, but after the array parameter is received, it acts on the original array. This question is a bit special, for the record, follow-up. ============================================================================ * * #include <stdio.h> #include <stdlib.h>int Main (void) {//occupies a memory size of 20 bytes int array[5]={1,2,3,4,5};p rintf ("main int array[5] size=%d\n", sizeof ( Array));p rintf ("===========\n"), int i;for (i=0;i<5;i++) {printf ("First array[%d]=%d\n", I,array[i]);} printf ("===========\n");//pass the array as a parameter to the other function Testarray (array); for (i = 0; i < 5; i++) {printf ("Second array[%d]=%d\n", I, Array[i]);} printf ("===========\n"); return exit_success;} void Testarray (int array[5]) {//Because the pass-through is just a pointer, so its size is 4 bytes of printf ("Testarray int array[5] size=%d\n", sizeof (array)); printf ("===========\n");//change the original array int i;foR (i = 0; i < 5; i++) {array[i] = Array[i] + 5;}}
An array of problems passed as arguments