An array of pointers, function

  C language to learn to know the array pointer has a special status in the c. And is a must master knowledge, learn it will benefit you immensely.

  First, the array

  1, the array: a series of the same elements that make up the roommate. It is stored in contiguous memory.

  2, the array declaration:

    Format: Type array name [element number];

    例 : int myarray[10];

    Note: The number of elements as the situation does not allow variables appear before the c99.

    Example:

      int n = 10;

      int myarray [n]; // C99 allowed before (this statement is not allowed to be initialized embodiment)

  3, the array initialization:

  •     int myarray [] = {1,2,3,4,5}; // correct, the number of elements can be omitted in this case.
  •     int myarray [10] = {1,2,3,4,5,6,7,8,9,0}; // In general, the intermediate element and the element of "," split
  •     int myarray [10] = {1,2,3}; // only three elements before initialization.
  •          int myarray [10] = {[4] = 4, [6] = 6}; // 5th 6th membered th element is initialized, the other elements are zero.
  •               int n = 10; int myarray [n] = {1,2,3,4,5,6,7,8,9,0}; // error. C99 After allowing variable as the number of elements in the array, but not allowed to initiate such a declaration.

    So if we do not initialize after the array definition, what is the value of the array elements?

      When array definition, just draw an area known as the name of the array to store the array elements. But this area does not change in the definition of an array of data in the time, that value in this area is uncertain.

  4, array-valued

    int myarray [10] = {1,2,3,4,5,6,7,8,9,0}; 

    int oarray [10];  

    oarray = myarray; // error, c did not support an array as a whole assignment.

    oarray [10] = {1,2,3,4,5,6,7,8,9,0}; // Error, c does not support a curly brackets assignment.

    

 

Guess you like

Origin www.cnblogs.com/yuanyongbin/p/7764205.html