Hi all--
I'm writing a program that initializes an integer double pointer to NULL, and realloc's it's size each time a particular method is called. Something like:
I'm not sure if this is the correct way of going about this, but you get the idea of what I'm trying to do.Code:int** list = NULL; void someMethod() {int* listElement = malloc(sizeof(int)*3);list = realloc(list, sizeof(list)+sizeof(listElement));}
Unfortunately, to test this-- I try printing the sizeof(list) before and after I realloc, and to my dismay-- the size is always 8.
1) Why is sizeof(list) always 8, even if I malloc it instead of initializing it to NULL?
2) How do I go about my intended program implementation?