C Language High-speed entry series (IV.)

Source: Internet
Author: User

C Language High-speed entry series (IV.)


C-language arrays


---------Reprint Please specify the Source: Coder-pig

Intimate tip: If the picture is not clear can be right-click Save As, should be very clear;

Note that the above code is to go through it yourself!


Introduction to this section:

Through our previous three series of learning, we have a certain understanding of C language;

It should not be difficult for you to write such a code now:

Enter five students ' scores, then calculate the sum and average, and print out the results!

I believe that we will first define five variables, to store five students ' scores, and then to calculate it!

However, if the required students are not 5 but 20, 50 or many others, do you define a bunch of variables?

This is obviously unwise in C, where we store the same number of data types in a single collection in order!

And such a collection is the sectionto of this array of learning!


Learning Roadmap for this section





1. One-dimensional arrays and two-dimensional arrays:




2. Strings and Arrays of strings





Summary:

The ① array is an ordered set of variables that store the same data type and can be used to access the elements in the array by subscript

② definition of one-dimensional array, initialization and reference

③ two-dimensional arrays for storing tabular data, defining, initializing, and referencing

④ distinguishes between strings and string arrays, strings are stored in a character array, and finally a '

The length of the ⑤ character array is at least greater than the string

⑥ uses sizeof (array name)/sizeof (the data type of the array element) to find the length of the character array

⑦ character array Direct = = The comparison result is a comparative address

⑦ uses the string manipulation functions provided by the STRING.H library:

strcpy (A, A, b) copies the strings of string A to a, overwriting strcat (A, A, A, b): the contents of String B. are spelled back to a

strcmp (A, A, b): A, b two strings from left to right for each character, according to the ASCII code value, the comparison, until the difference or ' ", the termination of the comparison

Assuming the same content, return 0;a greater than B returns a positive integer; A less than B returns a negative integer

Strlen (a): Returns the length of the string, not containing the string's end flag '




Learning Resources Download:


C Language High-speed entry series (IV.)

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.