为什么我们应该经常在C中对结构进行类型化呢?我见过许多由如下结构组成的程序typedef struct {
int i;
char k;} elem;elem user;为什么这么频繁地需要它?有什么具体原因或适用范围吗?
3 回答
扬帆大鱼
TA贡献1799条经验 获得超9个赞
struct
typedef struct {
int x, y;} Point;Point point_new(int x, int y){
Point a;
a.x = x;
a.y = y;
return a;}typedef
struct
typedef struct Point Point;Point * point_new(int x, int y);
struct
struct Point{
int x, y;};Point * point_new(int x, int y){
Point *p;
if((p = malloc(sizeof *p)) != NULL)
{
p->x = x;
p->y = y;
}
return p;}更新typedefstruct
- 3 回答
- 0 关注
- 410 浏览
添加回答
举报
0/150
提交
取消
