【发布时间】:2014-12-23 08:00:54
【问题描述】:
现在,当我打印块数组中的每个元素时,每个元素都有相同的地址。例如:
ints: 20 bytes stored at 0xbffa84fc
doubles: 80 bytes stored at 0xbffa84fc
chars: 8 bytes stored at 0xbffa84fc
Students: 1008 bytes stored at 0xbffa84fc
【问题讨论】:
-
通过添加打印代码进行了改进。但请记住,真正的"Minimal, Complete, Verifiable Example" 可以被复制粘贴和编译。这意味着 HeapType 和 BlockType 以及
#include <stdio.h>的正确包含和定义。然后问:你能证明这个问题让你感到困惑吗?你有四个mh_alloc电话...... 4 有什么特别之处而 2 无法证明?他们是否需要“int”和“double”类型,或者你可以减少它吗?少即是多,您可能会自己发现问题!
标签: c malloc dynamic-memory-allocation