Is it possible to find the Memory Allocated to the Pointer, without searching for the malloc statement

前端 未结 3 1934
执笔经年
执笔经年 2020-12-05 03:25

Suppose I have allocated memory to some pointer in a function foo:

void foo()
{    
    // ...  
    int *ptr = malloc(20*sizeof(int));  

    b         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 03:50

    No. You have to store that information yourself when you malloc().

提交回复
热议问题