[Courses] [C] Lesson12: Exercise answers

Eugene Teo eugene.teo at eugeneteo.net
Fri Nov 22 03:20:44 EST 2002


> Calloc is faster than malloc, but beware, they work quite different,
> malloc allocates memory from the heap, calloc allocates from the stack. 

correction: both allocates memory from the heap, just that calloc 
initialises the allocated memory with zeros. if you want to know why,
use extern _text, _data, and display allocated memory addresses, and
visualise the memory map.

Eugene
-- 
eMail: eugeneteo at eugeneteo.net, eugeneteo at null.cc.uic.edu
gpg pub_key: http://null.cc.uic.edu/~eugeneteo/eugeneteo.asc
main(i){putchar(182623909>>(i-1)*5&31|!!(i<7)<<6)&&main(++i);}




More information about the Courses mailing list