Why would one use realloc() function to resize an dynamically allocated array rather than using free() function before calling the malloc() function again (i.e. pros and con
The advantage is that realloc will preserve the contents of the memory. With free + malloc you'd need to reset the data in the array.