Finally, we decided to move towards software developers on the road to the future and review data structures and algorithms from now on.
Arrays have several interesting features.
1. For the array int list [3], the compiler interprets list [I] as a pointer to an integer with the address list + I * sizeof (INT.
For int * List and int * list2 [5], both are int-type variables, but the compiler will allocate the latter five integer buckets.
List2 actually points to list2 [0], and list2 + I is actually & list2 [I]. You do not need to add an offset in the C language. Therefore, * (list2 + I) = list2 [I];
2. in C language, arrays are used as parameters. functions that accept arrays as parameters do not actually allocate space to arrays repeatedly. It can be understood that when arrays are used as parameters, they only pass their addresses in, (Like address transfer), so changes to the parameter array in the function will also be reflected in the array itself.
/* For example */INT sum (INT list [], int N) // n is the dimension.
{
For (INT I = 0, I <n; I ++)
{
List [I] + = I;
}
}
Sum (A, 3 );
In this example, the real parameter A = & A [0] is first copied to a temporary Unit to become the specific value of the form parameter list. In the function body, if list [I] appears on the left of the value assignment statement, it indirectly references the value pointed to by (list + I). If list [I] appears on the right of the value assignment statement, the result on the right of the equal sign is saved to the unit (list + I ). this example tells us that although the C language function is called to pass values, the array as a function parameter does not pass the specific array content.
Data structure review notes-array