why memory is divided into Stack,heap,datasegment and code segment in c language?
Why memory is divided into Stack,heap,datasegment and code segment in c language?
I think the C language knows no such divisions in memory.
What you have asked applies to the C runtime environment. Stack holds locals. Heap holds local dynamic variables. data segment holds the initialised values. code segment holds the executable text.
If you look at the layout of an assembly program, it is pretty close to this arrangement. In early days of C, assemblers were available. So the developers had to translate a C code into an assembly code and let the assembler take over. That is to say, C is a portable, high-level assembly language.
So it is natural for the C run-time to be divided as you say.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment