+ 1
sizeof operator in malloced memory(C language)
How can I get no of total bytes in a malloced memory by using sizeof operator? as int* a=(int*) malloc(10*sizeof(int)) how can I get the total no of bytes used by the array by using sizeof operator?
2 Respostas
+ 2
Jyotiprakash Das Karmakar, IMO it's not possible... that's the reason we should keep track of allocated members count... in your code , a is pointer and same would give you size of pointer... *a is first element and same would give you size of int type.... also you can't be sure that howmnay elements are present in array as you can access next unallocated elements with few compilers....sm1 plz correct me if I m wrong
+ 2
Thanks...