小编Ant*_*igh的帖子

在C中初始化结构

我想要做的只是初始化一个struct的实例.结构在这里定义:

typedef struct Rectangle 
{
tName Name; /* name of the rectangle */
struct Rectangle * binSon[2];
int Center[2];
int Length[2]; /* distance to the boarder of the rectangle */
int Label;
}Rectangle;
Run Code Online (Sandbox Code Playgroud)

以及我如何初始化它如下所示:

Rectangle * binSon[2];
binSon[0] = NULL;
binSon[1] = NULL;

int Center[2];  
int Length[2];

Center[0] = 0;
Center[1] = 0;
Length[0] = 5;
Length[1] = 5;

Rectangle world = {"World", binSon, Center, Length, 0};
Run Code Online (Sandbox Code Playgroud)

在最后一行,当我编译程序时,它向我报告一个警告:

mx_cif_ds_manager.c:52:2: warning: initialization makes integer from pointer without a cast [enabled by …
Run Code Online (Sandbox Code Playgroud)

c struct

2
推荐指数
1
解决办法
4万
查看次数

标签 统计

c ×1

struct ×1