Consider the following code:
float d = 3.14f;
int i = 1;
auto sum = d + i;
According to cppreference.com, i
should be converte
In some compilers, files with a .c
extension are compiled as C, not C++.
float d = 3.14f;
int i = 1;
auto sum = d + i;
compiled as:
float d = 3.14f;
int i = 1;
int sum = d + i;
In the C language, auto
is a keyword for specifying a storage duration. When you create an auto
variable it has an “automatic storage duration”. We call these objects “local variables”. In C, all variables in functions are local by default. That’s why the keyword auto
is hardly ever used.
The auto
keyword is useless in the C language. It is there because before the C language there existed a B language in which that keyword was necessary for declaring local variables. (B was developed into NB, which became C.)