0

I wrote the below code , and i want to realize how much space i have totally reserved but if i use sizeof(p) it only returns the size of my pointer. how can i get 2000 ?

 void main(void){
      int *p = (int * )  malloc(sizeof(int) * 1000 ) ;
      //...The rest of the code comes here
      p = ( int * ) realloc ( sizeof(int) * 2000 ) ;
      // what function should i call with p in order to get
      // the size of the reserved space that p is pointing to ???? 
 }
BlueO
  • 3
  • 1
  • 1
    You can't, you have to keep track of that separately – UnholySheep Dec 02 '18 at 18:02
  • Possible duplicate of [Determine size of dynamically allocated memory in C](https://stackoverflow.com/questions/1281686/determine-size-of-dynamically-allocated-memory-in-c) – mnistic Dec 02 '18 at 20:00

0 Answers0