首页 > 其他分享 >C语言extern和static

C语言extern和static

时间:2023-02-03 09:13:05浏览次数:41  
标签:变量 int C语言 静态 static extern 形式参数

下面的代码段说明了变量和形式参数声明中怨念或者省略存储类型的所有可能的方法。

int a;
extern int b;
static int c;

void f(int d, register int e)
{
    auto int g;
    int h;
    static int i;
    extern int j;
    register int k;
}

下表说明了上述例子中每个变量和形式参数的性质。

变量和形式参数的性质
名字 存储期限 作用域 链接
a 静态 文件 外部
b  静态 文件
c  静态 文件 内部
d 自动
e 自动
g 自动
h 自动
i 静态
j 静态
k 自动

①由于这里没有显示出变量bj的定义,所以不能确定它们的链接。在大多数情况下,变量会定义在另一个文件中,并且具有外部链接。

在这4种存储类型之中,最重要的是externstaticauto没有任何效果,而现代编译器已经使register变得不如以前重要了。

标签:变量,int,C语言,静态,static,extern,形式参数
From: https://www.cnblogs.com/matrioc/p/17087985.html

相关文章

  • C语言学习: 快速排序(递归方式)
    1#include<stdio.h>2#include"io_utils.h"3#include<stdlib.h>4#include<time.h>56#definePLAYER_COUNT5078voidSwapElements(intarray[......
  • C语言学习: 数组打乱
    1#include<stdio.h>2#include"io_utils.h"3#include<stdlib.h>4#include<time.h>56#definePLAYER_COUNT5078voidSwapElement(intarray[]......
  • C语言学习 字符串
    如果文件编码是GBK,那么他会编译成GBK编码,存储起来。   内存里面这么存储。中文是GBK编码存储,而数字和英文,是以unicode编码存储   GBK编码查询   宽......
  • c语言中获取环境变量
    #include<stdio.h>intmain(intargc,char*argv[],char*envp){/**命令行传参的时候例如:mysqlmysql-h127.0.0.1-uroot-p123*argc传入......
  • C语言++前置与后置
    1.++前置#include<stdio.h>intmain(){inti=10,j=0;/*i=i++;*//*j=i++;*/j=++i;//先对i++,再赋值给jprintf("%d%d",i,j);i=11,b=11}2.++后置#includ......
  • Java static关键字
    java中的static关键字主要用于内存管理。我们可以应用javastatic关键字在变量,方法,块和嵌套类中。static关键字属于类,而不是类的实例。静态(static)可以是:变量(也称......
  • 《C语言实现http下载文件》
    源码:/************************************************************Copyright(C),2016,Leon,AllRightsReserved.FileName:download.ccoding:UTF-8Descript......
  • 【C语言】memset() 内存填充块
    ......
  • c语言-----指针例子
    指针的基本应用#include<stdio.h>intmain(){ inta=100,b=200; int*p_1,*p_2=&b; p_1=&a; printf("a=%d\n",a); printf("*p_1=%d\n",*p_1); printf("b=%d......
  • 初识C语言2
       今天主要学习了常量、字符串、转义字符、注释、选择语句、循环语句、函数、数组、操作符。常量:生活中不变的量。1、字面常量(如:3.14、3等)。2、const修饰的常变量(con......