"C Language Programming (fourth Edition)" Reading Experience (ii)

Source: Internet
Author: User

Sixth. Referencing an array to process bulk data

1. Definition of array: type-character array-name [constant-expression]

1) define an array in the main function, the constant expression cannot contain the variable

int a[3+5];   // Legal int N; int a[n];       // Not legal

2) in the function being called, the length can be a variable or a very expressive expression

void int N) {     int a[2// Legal, because the value of n is constant when executing a function }

3) in the C language, the array name represents the starting address of the array, and if the input entry in the SCANF function is an array of characters, do not add the address character &

2. Initialization of arrays

If you specify an array's length and initialize it when you define a numeric array, the system automatically initializes the array elements that are not initialized by the initialization list.

is 0 (if it is a character array, it is initialized to ' \ s ', and if it is a pointer-type array, it is initialized to null (null pointer) )

int a[1,2,3,4,5};  // only the first five elements are initialized, and the last five elements are 0

3. Initialization of two-dimensional arrays

int a[3[4] = {{1},{5},{9/*  Post-assignment element   1  0  0  0   5  0  0  0   9  0  0  0 */
int a[3[4// define an array of three rows four columns a[3] [43//  Illegal, array starting from 0, does not exist a[3][4]

"C Language Programming (fourth Edition)" Reading Experience (ii)

Related Article

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.