[prog] guide to memory in C, the stack, heap?

Angelina Carlton brat at magma.ca
Thu Feb 16 03:04:44 EST 2006


Hello

My C book barely touches on the stack and the heap and what really goes
on during function calls like malloc and free.

So I decided to look for a website that explains this. Google turned up
lots of hits and I started reading this page:

,----[ http://www.coronadoenterprises.com/extras/diagram.html ]
| Stack - The area that looks like a ladder on the right part of the
| diagram is the stack. The stack is allocated by the system to be a fixed
| size and is filled as needed from the bottom to the top one element at a
| time. Elements are removed from the top to the bottom one element at a
| time. Thus the last element added to the stack is the first element that
| is removed when no longer needed. Any element on the stack is
| potentially available for reference or modification by the executing
| code, but elements are added and removed only from the top.
`----

But something struck me as odd, it tells me the stack is "filled as
needed from the bottom to the top" but then ends by telling me all
elements are added and removed only from the top.

I was wondering if anyone has a better explanation in their bookmarks?

-- 
-----Angelina Carlton-----
orchid on irc.freenode.net
     brat at magma.ca
web:bzgirl.bakadigital.com
--------------------------


More information about the Programming mailing list