S
S. A. Hussain
Where Global variables created in STACK or HEAP in C/C++?
ve##tolimits[at]yahoo[dot]com, delete ##
ve##tolimits[at]yahoo[dot]com, delete ##
In said:Where Global variables created in STACK or HEAP in C/C++?
In said:Having said that, "Global" variables, those that are at file scope and can
be externed for use in other translation units are typcally not stored in
a stack-like region but are placed in what some implementations call .bss
or .data segments.
Or bss *and* data segments. The data segment is used for initialised
variables and the bss segment for the variables that get initialised by
default to all zeroes (on most implementations, all zeroes is good
enough for pointers and floating point variables, too).
Neither Global, STACK nor HEAP are mentioned in the C standard,
and are thus off-topic here.
I suspect you want a news group that deals with your particular OS
and/or compiler.
jemma said:Doesn't the last-in/first-out semantics of the scoping of local
variables (sorry, I mean 'automatic' variables) within nested blocks
describe a stack?
Aren't malloc() and free() the primary allocation and deallocation
routines for a data structure commonly known as a 'heap'?
Based solely on the excellent answers in reply to the OP's question
(most posted hours before your less-than-helpful one), maybe not. I
think you're being way too picky. I knew /exactly/ what the OP meant,
so did a number of other responders, and, I suspect, so did you.
Where Global variables created in STACK or HEAP in C/C++?
ve##tolimits[at]yahoo[dot]com, delete ##
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.