Variable properties of C language

Source: Internet
Author: User

You can add attribute keywords when defining variables.

1) Auto

Auto is the default property of the local variable in the C language.

Auto indicates that the modified variable is stored on the stack

The compiler defaults to all local variables that are auto

2) Register

The 1.register keyword indicates that local variables are stored in registers

2.register is just a request register variable, but not necessarily successful

The 3.register variable must be a value acceptable to the CPU register

4. The address of the register variable cannot be obtained with & (because the,& is the address in memory, and the register variable is stored in the register, of course you cannot use & to get the address of the register variable)

3) static

The 1.static keyword indicates the "static" property of the variable

Local variables----Static modifications are stored in the program static area

2.static Key has the meaning of "scope qualifier" at the same time

The scope of the global variable----The static adornment is only declared in the file

----The function scope of the static modifier is only in the declared file

4) extern

1.extern variables and functions for declaring "external" definitions

----extern variable to allocate space elsewhere in the file

----the extern function is defined elsewhere in the file

2.extern is used to "tell" compilers to compile using C

The C + + compiler and some other C compilers are different because of the developers, the different compilers will compile the functions and variables in their own way, but after the extern, they must follow the "standard C way to compile the program"


This article from "Van Gogh said my brain is sick" blog, declined reprint!

Variable properties of C language

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.