Ian Collins said:
Sorry, I can't let this go, while off topic, it is also wrong.
It's beyond wrong -- there's no guarantee that a "stack" or "heap" even
exists, much less what size it is.
There isn't a typical stack size as there isn't a typical environment,
there might not even be a stack. A multi-user system may default to 1
or 2 Mb of stack per thread, while an embedded one may be configured for
a few tens or hundreds of bytes.
The answer is very platform specific, thus off topic here.
<OT>
Most systems I'm familiar with have the heap grow upward from the "bottom"
of user memory and the stack grow "downward" from the top of user memory.
Either can grow until it meets the other, at which point the program usually
crashes within short order.
The only time you have a fixed stack size is when you create additional
threads; one thread's stack will grow down towards the heap as above, but
other threads' stacks will grow into another stack, which will (eventually)
cause problems even if there's plenty of memory left. This is when compiler
options on stack size become relevant. Of course, C doesn't mention threads
either.
</OT>
--
Stephen Sprunk "Stupid people surround themselves with smart
CCIE #3723 people. Smart people surround themselves with
K5SSS smart people who disagree with them." --Aaron Sorkin
*** ***