Are “malloc(sizeof(struct a *))” and “malloc(sizeof(struct a))” the same?

后端 未结 4 2288
鱼传尺愫
鱼传尺愫 2020-11-29 09:41

This question is a continuation of Malloc call crashing, but works elsewhere

I tried the following program and I found it working (i.e. not crashing - and this was m

4条回答
  •  余生分开走
    2020-11-29 10:31

    No.

    sizeof(struct a*) is the size of a pointer.
    sizeof(struct a) is the size of the entire struct.

提交回复
热议问题