Input and output of character array and two-point color platform for sale

Source: Internet
Author: User
Tags array length
* Input and output of character array

• The input and output of a character array can be in two ways: two-point color platform for sale (Enterprise e: 217 1793 408)
Enter the output individually. Enter or output a character with the format character "%c".

The entire string is entered or output at once. Use the "%s" format character, which means the input and output of the string.

Description

(1) When outputting a string with the "%s" format, the output item in the printf function is a character array name instead of an array element name.

(2) If the array length is greater than the actual length of the string, it will only output to the end of ′\0′.

(3) The output character does not include the Terminator ′\0′.

(4) If a character array contains more than one ′\0′, the output ends when the first ′\0′ is encountered.

(5) You can enter a string with the scanf function.

(6) If more than one string is entered using a scanf function, the input is separated by a space. For example: scanf (″%S%S%S″,STR1,STR2,STR3);

*strcpy function

strcpy is a "string copy function" in the general form: strcpy (character array 1, string 2)

(1) The character array 1 must be defined sufficiently large to accommodate the copied string. The length of the character array 1 should not be less than the length of the string 2.

(2) "character array 1" must be written in the form of an array name (such as str1), "String 2" can be a character array name, or it can be a string constant. such as: strcpy (Str1,″china″);

(3) The copy is copied to the character array 1, along with the ′\0′ after the string.

(4) You can use the strncpy function to copy the first number of characters in string 2 to the character array 1.

(5) You cannot use an assignment statement to give a string constant or an array of characters directly to an array of characters.

Input and output of character array and two-point color platform for sale

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.