How to check the memory allocated using malloc function.
How to check the memory allocated to mem.Code:int *mem; mem=(int *)malloc(sizeof(int));
How to check the memory allocated using malloc function.
How to check the memory allocated to mem.Code:int *mem; mem=(int *)malloc(sizeof(int));
How to check it manually?
Just do it theoretically, int is 4 bytes. The rest is easy.
What exactly do you want to "check"? There are only two valid return values from malloc(): NULL for a failed allocation, and a valid pointer to a block of the size you requested, which is ANY other value than NULL. [Assuming of course we are talking about a malloc() that is implemented by a normal system library, rather than "I built my own malloc function, and I want to check if it works"].
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.