本文介绍了如何获得的大小动态(使用malloc或释放calloc)分配的内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int **arrofptr;
arrofptr = (int **)malloc(sizeof(int *) * 2);
arrofptr[0] = (int *)malloc(sizeof(int)*6144);
arrofptr[1] = (int *)malloc(sizeof(int)*4800);

Now i have to know that how many bytes are allocated in arrofptr,arrofptr[0],arrofptr[1]? is there any way to know the size?

if we will print

sizeof(arrofptr);
sizeof(arrofptr[0]);
sizeof(arrofptr[1]);

then it will print 4

解决方案

No. Not without using extra data somewhere that stores the allocated sizes.

这篇关于如何获得的大小动态(使用malloc或释放calloc)分配的内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 03:50