C language pay attention to the problem-array

1. Introduction to arrays:

    A method that can solve a large number of the same type of data and frequently defined in the program. The array is divided into a one-bit array and a two-dimensional array according to the storage method, and can be divided into a numeric array, a character array, and a string array according to the content.

2. Array characteristics:

   1) The development within the space is continuous

  2) The array name is the first address of the array and the address of the first element of the array. All elements of the array can be accessed through the array name, which is very similar to the function.

3. Problems that should be paid attention to in the use of arrays:

  1) The length of the array needs to be given when it is defined. If the length is not given, it needs to be initialized and assigned when it is defined

  2) The array can only be assigned as a whole when it is initialized, otherwise it can only be assigned one by one

 3) The defined character does not have to be char, but can also be int and so on. .

 4) String array: real length = effective length +'\0', the terminator will occupy 1 data space

5) About character arrays and string arrays:

                char str ='a'; is a character array and also a string array

                char str[] = {'a','b','c'}; is a character array, not a string array

                char str[] = "abc" = {'a','b','c'.'\0'}; not a character array, but a string array

 

 

 

Guess you like

Origin blog.csdn.net/qq_45604814/article/details/109695247