[Gllug] data segment vs stack

Andy Farnsworth farnsaw at stonedoor.com
Tue Feb 14 12:29:12 UTC 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 ?
>  
>

Tim,
  Variables in the main function are exactly the same as variables other 
locations, they are created on the stack.

Andy
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list