定义外部变量
file1.c
include <stdio.h>
int A; /定义外部变量/
void main()
{
int power(int); /函数声明/
int b = 3, c, result, m;
printf("enter the number A and its power m:\n");
scanf("%d %d", &A, &m);
c = A * b;
printf("%d * %d = %d\n", A, b, c);
result = power(m);
printf("%d ^ %d = %d\n", A, m, result);
}
file2.c
extern A; /声明A为一个已定义的外部变量/
int power(int n)
{
int i, y = 1;
for(i=1; i <= n; i++)
{
y *= A;
}
return y;
}