C语言中如何申明外部定义的结构体数据。
展开全部
方法一:文件包含
//a.c
#include
#include
#include"c.c"
main()
{
int
b;
g->v=1;
b=a(1);
printf("%d",g->v);
}
//c.c
#include
int
a(int
x)
{
printf("%d",x);
return
0;
}
方法2;头文件
//a.c
#include
#include
#include
"b.h"
main()
{
int
b;
g->v=1;
b=a(1);
printf("%d",g->v);
}
//b.h定义一个头文件
int
a(int
x);
struct
gg;
//c.c
#include
int
a(int
x)
{
printf("%d",x);
return
0;
}
struct
gg
{
int
v;
}*g;
方法3:外部变量
//c.c
#include
extern
b
typedef
struct
gg
{
int
v;
}b,*g;
//a.c
#include
#include
#include"c.c"
main()
{
int
b;
g->v=1;
b=a(1);
printf("%d",g->v);
}
//c.c
#include
int
a(int
x)
{
printf("%d",x);
return
0;
}
方法2;头文件
//a.c
#include
#include
#include
"b.h"
main()
{
int
b;
g->v=1;
b=a(1);
printf("%d",g->v);
}
//b.h定义一个头文件
int
a(int
x);
struct
gg;
//c.c
#include
int
a(int
x)
{
printf("%d",x);
return
0;
}
struct
gg
{
int
v;
}*g;
方法3:外部变量
//c.c
#include
extern
b
typedef
struct
gg
{
int
v;
}b,*g;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |