Hi,
I have heard a question in C data storage i want to know where
the auto,static and global variables are get stored and what are the
memory segments like stack heap and its allocation.
All auto variables are placed into automatic storage.
All variables allocated with malloc() or calloc() are placed in
allocated storage.
All variables that are static or global have static duration.
Stack and heap do not appear in the standard. Many compilers place
automatic storage on a stack. Many compilers place allocated storage
on a heap. From the C language's perspective, understanding of the
physical location is not necessary to use the memory. There is no
imporant reason that all three types of storage could not be in the
same type of physical structures and general locations.
If you really want to know where something resides, take the address
of it (unless it is already an address) and (after casting to void *)
print the address with a %p format specifier. That will tell you
where the variable is located. Of course, it could be a symbolic
address running in a virtual machine, but that's neither here nor
there. You would get the compiler's view of where the data lives
exactly in any case.