一、auto
关键字的前世
从C语言开始,auto
关键字就被当作是一个变量的存储类型修饰符,表示自动变量(局部变量)。它不能被单独使用,否则编译器会给出警告。
#include <stdio.h>
int main()
{
int a = 123;
auto int b = 234;
auto c = 345;
printf("a = %d, b = %d, c = %d\n", a, b, c);
return 0;
}
编译运行结果:
$ gcc main.c
main.c:7:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
auto c = 345;
~~~~ ^
1 warning generated.