作用域 - 它们是局部的。
默认值 - 默认初始化值是垃圾值。
生命周期 - 在定义它的块的执行结束之前。
以下是c语言中寄存器变量的示例:
示例 演示
#include <stdio.h>int main() { register char x = 's'; register int a = 10; auto int b = 8; printf("the value of register variable b : %c
",x); printf("the sum of auto and register variable : %d",(a+b)); return 0;}
输出the value of register variable b : sthe sum of auto and register variable : 18
register关键字也可以与指针一起使用。它可以拥有内存位置的地址。它不会产生任何错误。
下面是c语言中register关键字的一个示例
示例 实时演示
#include<stdio.h>int main() { int i = 10; register int *a = &i; printf("the value of pointer : %d", *a); getchar(); return 0;}
输出the value of pointer : 10
以上就是在c语言中,“register”关键字的详细内容。
