• 吴裕雄--天生自然C语言开发:作用域规则


    #include <stdio.h>
     
    int main ()
    {
      /* 局部变量声明 */
      int a, b;
      int c;
     
      /* 实际初始化 */
      a = 10;
      b = 20;
      c = a + b;
     
      printf ("value of a = %d, b = %d and c = %d
    ", a, b, c);
     
      return 0;
    }
    #include <stdio.h>
     
    /* 全局变量声明 */
    int g;
     
    int main ()
    {
      /* 局部变量声明 */
      int a, b;
     
      /* 实际初始化 */
      a = 10;
      b = 20;
      g = a + b;
     
      printf ("value of a = %d, b = %d and g = %d
    ", a, b, g);
     
      return 0;
    }
    #include <stdio.h>
     
    /* 全局变量声明 */
    int g = 20;
     
    int main ()
    {
      /* 局部变量声明 */
      int g = 10;
     
      printf ("value of g = %d
    ",  g);
     
      return 0;
    }
    #include <stdio.h>
     
    /* 全局变量声明 */
    int a = 20;
     
    int main ()
    {
      /* 在主函数中的局部变量声明 */
      int a = 10;
      int b = 20;
      int c = 0;
      int sum(int, int);
     
      printf ("value of a in main() = %d
    ",  a);
      c = sum( a, b);
      printf ("value of c in main() = %d
    ",  c);
     
      return 0;
    }
     
    /* 添加两个整数的函数 */
    int sum(int a, int b)
    {
        printf ("value of a in sum() = %d
    ",  a);
        printf ("value of b in sum() = %d
    ",  b);
     
        return a + b;
    }
  • 相关阅读:
    Node.js安装及环境配置(windows)
    table
    检测浏览器
    ickeck插件
    全国三级联动
    css3-calc用法
    jQuery Portamento 滑动定位
    canvas版《俄罗斯方块》
    canvas入门级小游戏《开关灯》思路讲解
    css3 matrix 2D矩阵和canvas transform 2D矩阵
  • 原文地址:https://www.cnblogs.com/tszr/p/10968317.html
Copyright © 2020-2023  润新知