Determine size of dynamically allocated memory in C

后端 未结 15 2481
孤街浪徒
孤街浪徒 2020-11-22 06:15

Is there a way in C to find out the size of dynamically allocated memory?

For example, after

char* p = malloc (100);

Is there

15条回答
  •  自闭症患者
    2020-11-22 06:47

    If you use malloc then you can not get the size.

    In the other hand, if you use OS API to dynamically allocate memory, like Windows heap functions, then it's possible to do that.

提交回复
热议问题