C Language Learning (1) Array review

Source: Internet
Author: User

Topic 1: Using arrays to process data in batches  1. Arrays and loops are combined  2. The definition of an array  2.1) one-dimensional array: The type character array name [constant expression] 2.2] is defined to inform the computer to divide the corresponding memory  3. The reference  3.1 representation of the array element: array name [subscript] 4. Initialization of one-dimensional arrays   If you specify an array's length and initialize it when you define a numeric array, the array element that is initialized is not specified by the initialization list. The system automatically initializes them to 0 (if it is a character array, it is initialized to ' \ s ', if it is a pointer-type array, it is initialized to NULL, i.e. NULL pointer)    Topic 2: How to define and reference a two-dimensional array  1. General form of definition   type specifier The array name [constant expression] [constant expression] 2.float a[3][4] is equivalent to Flaot a[0][4], a[1][4], a[2][4];a[0],a[1],a[2] can be seen as an array name  3.c language, The order in which elements are arranged in a two-dimensional array is stored by row.  4. The reference  4.1 representation of a two-D array: array name [subscript] [subscript] 5. Character data is stored in the storage unit as ASCII code of characters, typically in one byte. Because ASCII is also an integral form, in the C99 standard, the character type is generalized to an integer type in a  6.c language without a string type, and the string is stored in a character array.  7. How to define the character array as above  8. By 5 You can store character data with an integer array.  9. If you do not initialize when you define a character array, the values of each element in the array are not predictable. The &NBSP;10.C system automatically adds an empty operator '% ' as a terminator when it uses a character array to store string constants in memory. This determines whether the output is stopped by checking for a terminator when outputting a character.  11. In addition to using regular methods to initialize an array, you can also initialize it with string constants.  12. One character occupies one byte. The length of the character array refers to the number of bytes that all characters occupy, including the ending character.  13. Character array output  13.1 characters-by-character input output:%c 13.2 outputs the entire string:%s, at which point the output item should be a character array name instead of an array element. &NBSP;13.3SCANF ("%s", c);//Enter a string into a defined array C to end the carriage return.  13.4scanf ("%s%s", c1,c2);//Enter more than one string into the defined array c1,c2 to end with a space character separating the carriage return.  14. In the C language, the array name represents the starting address of the array.  15. String handler function  15.1puts (array name) output string function  15.2gets (array name) input string function  15.3strcat (array name 1, array name 2) string Join function   15.4strcpy (array name 1, array name 2) the copy function of the string  15.5strncpy (array name 1, array name 2,2) copies the first 2 characters in the array 2 to the array 1, replacing the first 1 characters in the array 2. &NBSP;15.6STRMP (array name 1, array name 2) returns a 0 equal negative value that is less than the positive value is greater than  15.7strlen (array name 1) to measure the length of the string, excluding the terminator.  15.13.3 execution: First locate its array start address according to the character array name C, and then output the characters one after the other until you encounter ' \ '.    16. Use the string handler function to include the library function in response to it; #include <string.h>

C language Learning (1) Array review

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.