The seventh chapter of the Programming Basics array and string

Source: Internet
Author: User

Seventh chapter array and string

A summary:

1. The array is a collection of the same type, the array elements of the same array have the same data type, the reference array is a reference to the elements of the array, the change of the subscript can refer to any element of the array, note that the subscript does not cross the reference, that will bring side effects.

2. Array type plays a very important role in data processing and numerical calculation, and the combination of arrays and loops can solve many problems.

3. The array can be categorized according to the number of subscripts: one-dimensional arrays (one subscript) ...

The 4.C language uses a character array to hold the string, which contains a ' + ' character that represents the end of the string.

B parsing:

7.1: Basic Concepts of arrays

: arranged in a certain order, with a set of variables of the same type of the same nature.

7.2.1: one-dimensional arrays

Form: Data type array name [integer constant expression];

A: The subscript is starting from 0

7.2. References to 21-D arrays

Form: array name [subscript expression]

Note: The subscript cannot be crossed.

7.2. Initialization of 31-D arrays

Form: Data type array name [integer constant expression]={Initial value 1, initial value 2 ...};

1:

int a[4];

A[0]=1;

a[1]=2;

a[2]=3;

a[3]=4;

2:

int a[4]={1,2}; /* Will a[0]=1, a[1]=2, other values default to 0*/

3:

int a[]={1,2,3}/* where subscript is specified as 3*/

7.2. Application of 41-dimensional arrays

7.3 Two-dimensional arrays

7.3.1 Definition:

Form: Data type array name [integer constant expression] [integer constant expression],..........

int A[2][3]/* The previous subscript represents the row, and the subscript represents the column */

7.3. References to 22-D arrays

Form: array name [row subscript expression] [column subscript expression]

7.3. Initialization of 32-D arrays

Form: Array name of data type [integer constant expression] [integer constant expression]={initialization data};

7.3. Application of 42-dimensional arrays

Student Achievement

7.4 Character array and string

1: The C language uses a character array to hold the string, which contains a ' + ' character that represents the end of the string.

2: Each element of a character array occupies one character. And each time the placeholder will be a bit more, because the end of ' s ' will be a character.

The seventh chapter of the Programming Basics array and string

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.