static--静态变量

在下列代码中 关键词 “static”的用处:

在函数体内,被声明的变量count为静态变量,在counter函数被调用时,count 的值不变;

所以

第一张图的    该代码的结果为15

[root@localhost interview]# gcc static.c
[root@localhost interview]# ./a.out
j = 15

[root@localhost interview]#


第二张图的代码的结果是为5

[root@localhost interview]# gcc static.c

[root@localhost interview]# ./a.out

j = 5

[root@localhost interview]#


 

发布了3 篇原创文章 · 获赞 0 · 访问量 2637

猜你喜欢

转载自blog.csdn.net/qq_32942215/article/details/64997133
今日推荐