C 语言教程 C 练习实例41 - static

mason · 2022-04-04 13:16:42 · 热度: 9

题目:学习static定义静态变量的用法。

程序分析:无。

实例

// Created by www.codercto.com on 15/11/9. // Copyright © 2015年 码农 教程. All rights reserved. // #include<stdio.h> int main() { void fun(); for(int i=0;i<3;i++) fun(); return 0; } void fun() { int i=0; static int static_i=0; printf("i=%d\n",i); printf("static_i=%d\n",static_i); i++; static_i++; }

以上实例输出结果为:

i=0
static_i=0
i=0
static_i=1
i=0
static_i=2

查看更多 C 语言经典100例

猜你喜欢:
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册