* Character Array *

Source: Internet
Author: User

The difference between a character array and a character pointer variable:

Char *"I Love china! " // It is legal to assign the first initial address of I love china! to the pointer variable a

However:

Char str["I Love china! " // It's illegal, not too easy to think.

The following errors are also true:

Char *A; scanf ("%s"// Illegal, attempt to enter a string from the keyboard and make a point to it, which is easy to understand, Nor does it open space to store it

This is the only way to be correct:

Char *a, str[= str;scanf ("%s", a);  From the keyboard input string into a point of memory

The value of each element in the character array can be changed, and it can be assigned again, but the value of the string constant pointed to by the character pointer cannot be changed because the string constant is stored in the literal constant area and cannot be changed.

* Character Array *

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.