The storage categories in the C language are divided into four categories: auto (auto), Static, register (register), and external (extern).

Source: Internet
Author: User

Note In the division operation:

If the two digits of the division are integers, then the result is an integer, the fractional part is omitted, such as 8/3 = 2, and two is a decimal , and The result is a decimal number, such as: 9.0/2 = 4.500000.

Take note of the remainder operation:

This operation is only suitable for two integers , such as: 10%3 = 1, while 10.0%3 is wrong; The post-op symbol depends on the symbol being modulo, such as (-10)%3 =-1; and 10% (-3) = 1.

--

The storage categories in the C language are divided into four categories: auto (auto), Static, register (register), and external (extern).

1, the keyword Auto defines the variable as an automatic variable, auto can be omitted, auto does not write is implicitly defined as "Automatic storage category", belongs to the dynamic storage mode

2, static variables modified with static, if defined inside the function, called static local variables, if defined outside the function, called static external variables. The following is a static local variable:

Note: Static local variables are static storage classes that allocate storage units within a static store, are not released during the entire run of the program, and static local variables are assigned initial values at compile time, that is, only once , if the initial value is not assigned when local variables are defined. For static local variables, the compiler automatically assigns initial values of 0 (to numeric variables) or null characters (to character variables).

3, in order to improve efficiency, C language allows the local variable value is placed in the register in the CPU, this variable is called "register variable", with the keyword register as a declaration. For example:

Note: only local automatic variables and formal parameters can be used as register variables ; a computer system has a limited number of registers and cannot define any number of register variables ; Local static variables cannot be defined as register variables.

4. The variable declared with extern is an external variable, and the meaning of the external variable is that a function can invoke a variable defined after the function.

In the C language can not be called by other source file function appellation intrinsic function , the internal function is defined by the static keyword, and therefore is called static function, in the form of:

static [ data type] Function name ([parameter])

The static here is a limitation on the scope of the function, qualifying the function to be used only in the source file in which it is located, so that there is no problem with the intrinsic function name of the same function in different files.

Functions that can be called by other source files in the C language are external functions, which are defined by the extern keyword in the form:

extern [ data type] Function name ([parameter])

The C language specifies that when the function is not scoped, the system defaults to an external function, so that extern can also be omitted when an external function needs to be defined.

When there is no initialization after declaring the array, the static (static) and outer (extern) types of the array element initialize the element to 0, and the element initialization value of the automatic (auto) type array is indeterminate.

The storage categories in the C language are divided into four categories: auto (auto), Static, register (register), and external (extern).

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.