I'm grappling with understanding dynamic memory allocation and reallocation in C, particularly the intricacies of the realloc function. To illustrate my confusion, let's consider the following scenario:
Program initially allocate dynamic memory for three variables with values 30, 31, and 32, resulting in memory locations 30, 31, and 32. Now, if I want to add two extra numbers but find that memory locations 33 and 34 are already occupied by other variables, and memory is available from location 35.
My question is: What happens when I use the realloc function in this situation? How does it handle the case where the desired memory locations are already in use?
Program initially allocate dynamic memory for three variables with values 30, 31, and 32, resulting in memory locations 30, 31, and 32. Now, if I want to add two extra numbers but find that memory locations 33 and 34 are already occupied by other variables, and memory is available from location 35.
My question is: What happens when I use the realloc function in this situation? How does it handle the case where the desired memory locations are already in use?