外部变量

目录下新建 extern.h 文件,代码如下。

extern int i = 233;

执行下面的代码,即可访问外部变量。

#include <stdio.h>
#include "extern.h"

int main(int argc, char const *argv[])
{
    printf("%d\n", i);
    return 0;
}

results matching ""

    No results matching ""