|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
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;
}
将外部变量扩展到其他文件
file1与file2之间啥关系(知道是file1已定义的外部变量扩展到file2),,我想问的不是这个,在vs2013中是2个不同文件、不同工作空间吗?
|
|