C语言 extern4 全局数组

headB.h中:

#ifndef headB_H
#define headB_H
int i = 888;
int arr[5]={1,2,4,5,3};
#endif

.c文件中:

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

void main()

{
    int j=0;
    for (;j<5;j++)
    {
        printf("  %d",arr[j]);
    }
    
    printf("
%d",i);
}

结果:

1 2 4 5 3
888  请按任意键继续. . .

原文地址:https://www.cnblogs.com/shuqingstudy/p/4734526.html