相关疑难解决方法(0)

第一个元素偏移

它是保证,结构的第一个元素的偏移是0吗?为了更准确,我们考虑一下

struct foo {
int a;
double b;
};
struct foo *ptr=malloc(sizeof(struct foo));
int *int_ptr = &ptr->a;
free(int_ptr)
Run Code Online (Sandbox Code Playgroud)

在任何操作系统或任何其他因素下,它是否始终有效?

c malloc free offset

3
推荐指数
1
解决办法
126
查看次数

标签 统计

c ×1

free ×1

malloc ×1

offset ×1