Chinaunix首页 | 论坛 | 博客
  • 博客访问: 336417
  • 博文数量: 92
  • 博客积分: 2500
  • 博客等级: 少校
  • 技术积分: 960
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-21 19:38
文章分类

全部博文(92)

文章存档

2010年(71)

2009年(21)

我的朋友

分类: 嵌入式

2010-10-14 16:44:07

结构体中含结构体指针问题

 

int main(void)

 {

 struct Zeni_MTS_Position                      //坐标点  

{

         float Longitude;                          //位置点纬度,单位度

         float Latitude;                           //位置点经度,单位度

};

             

struct Zeni_MTS_Polygon_Fence                //多边形的顶点数和多边形顶点坐标

{

         int PositionCount;                                   //多边形顶点数

         struct Zeni_MTS_Position  *Vertex;         //多边形顶点坐标,顶点必须连续地组成多边形

};

 

struct Zeni_MTS_Polygon_Fence polygon;

struct Zeni_MTS_Position test_Pos[5];

 

   polygon.Vertex=test_Pos;

 

   polygon.Vertex[1]->Longitude = 20;           //错误的

   polygon.Vertex.Longitude = 20;                   //错误的

   polygon.Vertex[1].Longitude = 20;              //正确的

   (polygon.Vertex+1)->Longitude = 20;         //正确的

 

   printf("a=%f",(polygon.Vertex+1)->Longitude);

 }

阅读(1419) | 评论(0) | 转发(0) |
0

上一篇:结构体做参数的函数

下一篇:写写函数

给主人留下些什么吧!~~