小编Mic*_*end的帖子

存储在堆栈或堆中的结构

我有以下脚本:

typedef struct {
    uint8_t red;
    uint8_t green;
    uint8_t blue;
} color;

color c1;
color* c2 = malloc(sizeof(color));
Run Code Online (Sandbox Code Playgroud)

我想知道 c1 和 c2 的存储位置。我知道 malloc 存储在堆上,但是 c2 是一个指针并且那些存储在堆栈中?c1 是存储在堆上还是堆栈上?

c memory struct allocation

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

标签 统计

allocation ×1

c ×1

memory ×1

struct ×1