Review summary of C language, global variables, local variables, external functions, intrinsic functions, stasic and extern

Source: Internet
Author: User

Local Variables

definition: A variable defined inside a code block

scope: Start with the line that defines the variable until the end of the code block

life cycle: Allocates storage space from the row that defines the variable, which is recycled when the code block ends

No default initial value

Global Variables

definition: A variable defined outside a function

scope: Starts at the line that defines the variable and ends at the end of the file (can be shared by all subsequent functions)

life cycle: When a program starts, it allocates storage space and is destroyed when the program exits.

The default initial value is 0

Global variables are divided into external variables and internal variables

External variables: defined variables can be accessed by this file and other files, by default all global variables are external variables

Internal variables: defined variables can only be accessed by this file and cannot be accessed by other files

intrinsic functions: Defined functions can only be used in this file, other files cannot be accessed

allow intrinsic functions with the same name in different files

External functions: Defined functions can be accessed by other files

By default, all functions are external functions

external functions with the same name are not allowed

Static and the extern

valid for both functions and variables

static defines and declares intrinsic functions, defines an internal variable

Static modifies local variables, extends the life cycle of local variables, is destroyed at the end of the program, and does not change the scope of local variables

extern defines and declares an external function, declares an external variable

Review summary of C language, global variables, local variables, external functions, intrinsic functions, stasic and extern

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.