1.06-变量使用注意

来源:互联网 发布:神盾局特工 知乎 编辑:程序博客网 时间:2024/04/29 22:44

#include <stdio.h>


/*

 1.作用域(作用范围)

  从定义变量的那行代码开始,一直到函数结束

 */


int test()

{

   int score =200;

   return0;

}



int main()

{

   int score;

    

    test();

    

    score =100;

    

    

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

    

   /*

     错误写法

    int b;

    b = a;

    */

    

   int c =20;

    

   int a =10;

    

   return0;// 退出函数

}

0 0