I'm trying to learn c and implementing some basic memory allocations.
When I either malloc, calloc or realloc a pointer to int, every time I end up with the same chunk of memory of 8 bytes even when I'm initializing it with malloc with 20 bytes.
How to solve this?
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
int main()
{
int* ptr = (int*) malloc(sizeof(int) * 5);
printf("%d\n", sizeof(ptr) / sizeof(ptr[0]));
ptr = (int*) realloc(ptr, 10 * sizeof(int));
printf("%d\n", sizeof(ptr) / sizeof(ptr[0]));
return 0;
}