typedef struct testone
{
int x;
int y;
}t1;
typedef struct testtwo
{
t1 *t;
t->x curr_x
}t2;
I am getting the below error, anyone know what the problem is?
error: expected specifier-qualifier-list before 't'
Thanks
t->x isn't a defined type. all variables in structs, and in general, must be a type either defined by c or defined by you. I think what you are trying to do is have
typedef struct testtwo
{
t1 *t;
int curr_x;
}t2;
and then when you intialize a t2 struct you can assign the t1->x value to t2.curr_x
When you use x->y
, You should initialize address of y
in x
, It's normal to get error. So You can use old style such as xy
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.