开发者社区 问答 正文

Static修饰局部变量表现在哪里?

Static修饰局部变量表现在哪里?

展开
收起
游客gaxazmvfuhuj2 2022-03-29 16:57:58 487 分享
分享
版权
举报
1 条回答
写回答
取消 提交回答
  • #include<stdio.h>

    Void testFunc() {

    //静态局部变量

    /*

    根据结果我们推测:

    static修饰[局部]变量

    numbe r的内存并没有在函数结束调用的时候得以释放 stat ic修饰的局部变量只初始化一次 */

    static int number= 9;

    printf ("number = %d %p\n" ,number++, &number) ;

    }

    Int num1=10;

    int main(int argc, const char * argv[ ] ) {

    for (int i=0; i<10; i++) {

    testFunc() ;

    }

    // insert code here...

    printf("Hello, World!\n");

    return 0;

    2022-03-29 16:58:34 举报
    赞同 评论

    评论

    全部评论 (0)

    登录后可评论
问答地址:
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等