您的位置:首页 > 其它

1.07-变量使用注意2

2015-07-27 09:00 204 查看
#include <stdio.h>

/*

 1.变量的作用域

 从定义变量的那一行代码开始,一直到所在的代码块结束

 

 2.代码块的作用

 及时回收不再使用的变量,为了提升性能

 */

int test()
{
   int v =
10;
   return
0;
}

int main()
{
    {
       double height =
1.55;

        
        height = height +1;

        
        printf("height=%f\n", height);
    }

    
  /*

    {

        int a = 10;

    }

    

    printf("a=%d\n", a);*/

    

    
   int score =
100;

    
    {
       int score =
200;

        
        {
           int score;
            score =50;
        }

        
        printf("score=%d\n", score);
    }

    
    printf("score=%d\n", score);

    

    
   return
0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  01-基本语法