#include <stdio.h>
#include <stdlib.h>
int main()
{
int *ptr = malloc(sizeof(int));
if (ptr)
{
printf("Allocated bytes : %zu\n", sizeof *ptr);
}
int *newPtr = realloc(ptr, 10 * sizeof(int));
if (newPtr)
{
printf("After New Allocation\n");
printf("Memory Size is : %zu\n", 10 * sizeof(int));
free(newPtr);
}
else
{
free(newPtr);
}
return 0;
}
Posted inC Programming