The static variable in C

Source: Internet
Author: User

When a process's global variable is declared as static, its Chinese name is called a static global variable. There is no difference between a static global variable and a storage location for other global variables, but it is only valid within the source file that defines it, and other source files cannot access it.

The static local variable is called a statically local variable. It differs from ordinary local variables in the following different aspects:

1) Location: The static local variable is placed in the global store by the compiler, so it is local, but exists throughout the lifetime of the program.

2) Access rights: Static local variables can only be accessed by variables or functions within their scope. This means that although it will exist throughout the life of the program, because it is static, it cannot be accessed by other functions and source files.

3) Value: If the static local variable is not initialized by the user, it is automatically assigned a value of 0 by the compiler, and the last call value is used each time the static local variable is called.

Copyright NOTICE: This article is the original blogger articles, reproduced please indicate the source.

The static variable in C

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.