Home > Backend Development > C#.Net Tutorial > What does auto mean in c language

What does auto mean in c language

云罗郡主
Release: 2019-01-15 09:58:23
Original
53004 people have browsed it

Speaking of auto, I believe many people don’t know what it means. Below, php Chinese website will lead you to learn what auto means in C language.

What does auto mean in c language

auto is a keyword in C language. The keyword is mainly used to declare that the lifetime of variables is automatic, that is, not in any class, structure, enumeration, union and function. Variables defined in are considered global variables, while variables defined within functions are considered local variables. This keyword is not often written because all variables are auto by default.

The C language provides four storage categories described by the storage specifiers auto, register, extern, and static. The four storage class specifiers have two storage periods: automatic storage period and static storage period. Among them, auto and register correspond to the automatic storage period. A variable with automatic storage period is created when entering the program block in which the variable is declared. It exists while the program block is active and is destroyed when exiting the program block.

The language includes the keyword auto, which can be used to define local variables. But since the default value of all non-global variables is assumed to be auto, auto is rarely used. In C or previous C, the auto keyword can basically be ignored: for example, this local variable: int a = 100; auto int a = 100; there is no difference.

But in VC2010, auto has a new meaning. It can infer the type so that when we use it, we can auto a = 100; then a is of type int, and the initial value is 100.


The above is the detailed content of What does auto mean in c language. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template