Home > Backend Development > C#.Net Tutorial > What does auto mean?

What does auto mean?

云罗郡主
Release: 2021-04-16 14:58:13
Original
130608 people have browsed it

auto is a storage type in the C language and is used inside a statement. The biggest feature of auto is that when the execution flow enters the statement block, the initialization can be any expression.

What does auto mean?

The operating environment of this article: linux5.9.8 system, Dell G3 computer, C.

Many people have heard of auto, but they don’t know what auto means, let alone the usage of auto in C and C language. The following PHP Chinese website will tell you about auto.

1: What does auto mean?

auto is a storage type in the C language and is used inside statements. The biggest feature of auto is that when executing the process When entering a statement block, the initialization can be any expression.

2: The role of C language and C

1. In C 98, auto is an automatic storage variable, and it also declares a temporary variable. However, in the C 11 standard, auto means automatically inferring the type of a variable. There is also a restriction on the keyword, which is to assign an initial value to the declaration. If the initial value is not set, an error may occur. Introduced in c auot has two uses, one is to infer the return value placeholder and the automatic type, as follows:

auto x=5.2;//
Copy after login

where x means that auto is inferred as double

2. In c language, auto is the keyword that represents local variables, and it also requires declaring a variable. For example:

auto double a=3.7
Copy after login

a represents a temporary variable.

3: Precautions for using auto

When using auto, we can use some valatile for modification, but the declared variable must be initialized, but It cannot be used with other types at the same time. Of course, the template parameters of the function cannot declare auto at the same time, nor can user type conversion and other operations be performed. When we define an auto sequence variable, it must be deduced to the same type.

The above is a complete introduction to what auto means. If you want to know more about C tutorial, please pay attention to the php Chinese website.

The above is the detailed content of What does auto mean?. 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