Character array Initialization

Source: Internet
Author: User
There is no essential difference between the initialization of character arrays and the initialization of numeric arrays. However, in addition to assigning characters to array elements one by one, it can also be initialized directly with strings. (1) Use character constants to initialize arrays one by one. For example, char a [8] = {'I', 'l', 'O', 'V', 'E', 'y', 'O ', 'U'}; the method of initialization one by one is essentially the same as that of the numeric array initialization. You can also perform full initial value assignment and incomplete initial value assignment, however, when values are not completely assigned, elements that are not assigned values are assigned spaces. The length description can be omitted when an initial value is assigned to all elements. For example: Char C [] = {'C', '', 'P', 'R', 'O', 'G', 'R', 'A ', 'M'}; the length of the C array is automatically set to 9. (2) Initialize an array of string constants. For example: Char C [] = {'C', '', 'P', 'R', 'O', 'G', 'R', 'A ', 'M'}; can be written as: Char C [] = {"C program"}; or remove {} and write as: Char C [] = "C program ";

Character array Initialization

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.