我想在不同的文件之间共享一个结构。我的问题是:我想访问由某个文件中的函数定义的结构,由另一个文件中定义的另一个函数。
file1.c
#include<struct.h>
int main(){
//I want to access test1 variables here
printf("%d",test1.x);
printf("%d",test1.y);
.
.
}
file2.c
#include<struct.h>
int fun(){
.
struct test test1;
test1.x=1;
test1.y=13;
.
.
.
}
struct.h
struct test{
int x;
string y;
};
.
//Initialize some structure
.
.
}
我做对了..请告诉我我该怎么做..??我无法在 main() 中看到变量 test1
我正在使用 MS Visual Studio 2012