I want to be able to vary the size of my array so I create one this way:
int* array;
array = malloc(sizeof(int)*10);//10 integer elements
I can use this like an array as you normally would, however when I try to find the size of it like so:
size = sizeof(array)/sizeof(int);
I get the answer 1 because its not recognizing it as pointing to an array
How can I get the size of the array ? (I know its not technically an array but is there a way to work out the whole size of the allocated memory block ?)
Also am I right in assuming what I have stated in the description ? If I am technically wrong about something please correct me.
sizeof
doesn't know aboutmalloc
. – Crunode