Hai,
This situation will never arise in computers.But still to understand the difference between malloc and calloc i just visualised the situation.The situation is"consider the RAM in computer which has only bytes 10000 to 10007 and 10028 and 10029 left free.All other portion of memory are used for other purposes."Now what will happen if i give malloc(10) and calloc(5,2)?
One of my friends said that malloc will not allocate memory as there is no continuous group of 10 bytes.Yet calloc will allocate memory.I have two doubts arising from that?They are
1)Is that correct?
2)If so, what will happen if the ram has memory locations 10000 to 10006 and 10027 to 10029 left free,
all other portion of memory are used for other purposes and i give the command calloc(5,2)?Wil l it allocate memory or not?
Thanks for your reply in advance.
This situation will never arise in computers.But still to understand the difference between malloc and calloc i just visualised the situation.The situation is"consider the RAM in computer which has only bytes 10000 to 10007 and 10028 and 10029 left free.All other portion of memory are used for other purposes."Now what will happen if i give malloc(10) and calloc(5,2)?
One of my friends said that malloc will not allocate memory as there is no continuous group of 10 bytes.Yet calloc will allocate memory.I have two doubts arising from that?They are
1)Is that correct?
2)If so, what will happen if the ram has memory locations 10000 to 10006 and 10027 to 10029 left free,
all other portion of memory are used for other purposes and i give the command calloc(5,2)?Wil l it allocate memory or not?
Thanks for your reply in advance.
Comment