Run ❯
Get your
own
website
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
#include
#include
int main() { int *ptr1, *ptr2, size; // Allocate memory for four integers size = 4 * sizeof(*ptr1); ptr1 = malloc(size); printf("%d bytes allocated at address %p \n", size, ptr1); // Resize the memory to hold six integers size = 6 * sizeof(*ptr1); ptr2 = realloc(ptr1, size); printf("%d bytes reallocated at address %p \n", size, ptr2); return 0; }
16 bytes allocated at address 0x5640317512a0
24 bytes reallocated at address 0x5640317512a0