[Gllug] data segment vs stack
Christian Smith
csmith at micromuse.com
Tue Feb 14 12:20:43 UTC 2006
On Tue, 14 Feb 2006, t.clarke wrote:
>Hi
>
>Apologies if this question seems silly, but I am just curious as to whether
>the variables declared in the 'main()' function of a C program are created
>in the program's stack (in the same manner as variables declared in any
>'subsidiary' functions), or in the data segment (which is where I assume
>'global' variables are created?)
>
>Can anyone enlighten me or point to a web resource that explains ?
main() is just a function like any other C function, and is special only
to the C run time as the entry point for user code. So any variables
declared within main() are local and therefore stack based. You can even
call main() recursively.
>
>Tim
>
>--------------------------------------------------------------------------------
>This E-Mail (and any files transmitted with it) is intended solely for the use
>of the individual or entity to whom it is addressed. If you have received it in
>error please notify the sender and delete the message.
>
>
--
/"\
\ / ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
X - AGAINST MS ATTACHMENTS
/ \
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list