Can someone tell me the difference between malloc and calloc, from the memory allocation point of view.
thank you.
Can someone tell me the difference between malloc and calloc, from the memory allocation point of view.
thank you.
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
calloc fills the memory with all bits zero, malloc does not. Other than that (and their interfaces) they are identical.
My best code is written with the delete key.
Dave, can you please explain this line from the link you posted:
The zero fill is all-bits-zero, and does not therefore guarantee useful null pointer values
thank you
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
According to the standard, NULL is not guaranteed to be 0. So on those systems, you shouldn't rely on calloc() to initialize pointer to NULL.
If you understand what you're doing, you're not learning anything.
got it, thanks
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.