C and pointer Chapter 3-Data

Source: Internet
Author: User

Overview:

Chapter 3 of C and pointer describes the data.

This section mainly describes three attributes of a variable: scope, link property, and storage type.

These three attributes determine where the variable can be used and how long the value of the variable remains ".

 

Summary scope:

1. File Scope, code block scope, prototype scope, and function Scope

File Scope: The identifier File Scope declared outside the code block

Code block scope: declared in {}

Prototype scope: int getscore (INT ucstudent); in this function prototype declaration, int ucstudent has the prototype scope.

Function scope: Skip this.

Summary Link Attributes:

Link Attributes: external (external link attributes), internal (internal Link Attributes), and none (without Link Attributes)

Functions of Link Attributes: The Link property of the identifier determines how the identifier appears in different source files.

For example, the same identifier A appears in different source files. When these source files are compiled to form the target file,

When the next link is used to form an executable file, a indicates whether the same object is a different object, which is determined by the link attribute of.

External: an identifier with an external link attribute. No matter how many times it is declared, the object is the same regardless of the source file.

Internal: When a has the intonernal link attribute, the declaration in the same source file points to the same entity, and multiple declarations in different source files belong to different entities.

None: the declarations of the same or different source files point to different entities.

1. All variables with file scopes are "external Link Attributes" by default"

2. The variable declared in the function or code block is "NONE" by default.

3. Static and extern can change the link attribute of the identifier, but they have the following restrictions:

1) static: only declarations with the default external attribute change.

2) When the extern keyword is used for the first declaration of an identifier in the source file, it has the effect of modifying the link attribute, but is used for the second or later Declaration of the identifier

The link attribute declared for the first time will not be changed.

Summary Storage types

Storage type refers to the memory type in which the variable value is stored.

Static Normal memory Global variables, static global variables, and static local variables
Automatic Storage Type Stored in the stack Local variable
Register Stored in registers Variable modified by the register keyword

C and pointer Chapter 3-Data

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.