I’m creating the following buffer:
char *buffer;
int buffer_size = 1024;
buffer = (char*) ( malloc(buffer_size * sizeof(char) );
Then when I do:
int actual_size = sizeof(buffer);
printf("Size: %d", actual_size);
What it prints is:
size: 4
While I would expect it to be 1024, why is this?
This does not work like that
returns the size of
bufferwhich is a pointer, not an array. If you have an array such as the followingthen
would return 100 because
szArrayis an array, but a pointer is not an array.