So, while writeing a program I realised that when using realloc in a function outside of main if the original block of memory was declaired in main it doesnt seem to keep the changes outside of the function. E.G.
void main()
{
int *ptr;
//allocates memory
ptr = calloc(4, sizeof(int));
exampleFunction(&ptr);
} //end main
//this function reallocates the memory block of ptr
void exampleFunction(int *ptr)
{
ptr = realloc(ptr, (sizeof(int) * 10));
} // end exampleFunction
Do I need to do something different or should this work fine? Also this is just example code and is not intended to be runnable
Extra info I am using MinGW on windows 10