gpt4 book ai didi

c - 右箭头等于右箭头

转载 作者:行者123 更新时间:2023-11-30 14:52:01 25 4
gpt4 key购买 nike

我在某人的代码中看到了一些我不理解的内容。 return 语句中写了什么?

static cell_ptr UD_self(cell_ptr c) { return c->U = c->D = c; }

这里定义:

struct cell_s;
typedef struct cell_s *cell_ptr;
struct cell_s {
cell_ptr U, D, L, R;
int n;
union {
cell_ptr c;
int s;
};
};

最佳答案

这只是一种简写方式:

{
c->D = c;
c->U = c->D;
return c->U;
}

语句return c->U = c->D = c;之所以有效,是因为赋值运算符=返回刚刚分配的值。然后在下一次分配中使用该值。它是从右到左关联的,所以它的意思是return (c->U = (c->D = c));

关于c - 右箭头等于右箭头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47812919/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com