C结构体问题

来源:百度知道 编辑:UC知道 时间:2024/09/21 03:19:13
typedef struct {

unsigned int up : 1;

unsigned int right : 1;

unsigned int down : 1;

unsigned int left : 1;

unsigned int path : 1;

unsigned int visited : 1;

} cell_t;

typedef cell_t *maze_t;

这是什么格式呢, typedef在这里有什么用?

是[位段]
将一个字节的内存分给多个变量
节约存储空间用的
typedef是定义一种数据类型
e.g:
typedef struct
{`````
````
}cell_t;
等价
typedef struct
{````````
``````
};
```````
``````
void main()
{
typedef cell_t;
```
}