Can someone tell me what is a 'text segment' in C, and if possible show me a simple example?
Memory Segments in C — Text Segment
segments are not programming concepts, they're how code and data are laid out in executable files and in memory when a program is running. Take a look at the documentation for your linker for some possible hints. –
Rosierosily
The 'text' segment of a program on Unix systems is the code — the machine code, the functions that make up the program (including, in particular, main()
if the program is written in C or C++). It can also include read-only data. The other segments in a classic program are the 'data' segment and the 'bss' segment. The 'data' segment holds initialized data; the 'bss' segment holds zeroed data. Once running, the data and bss segments are indistinguishable.
You also end up with the stack and 'the heap'.
Yes I've understood all other memory segments. So correct me if i'm wrong the main() in a c program is the text segment? –
Antitoxin
The
main()
is in the text segment; so are the functions it calls. –
Inelegant Great that's what I wanted to know :) –
Antitoxin
© 2022 - 2024 — McMap. All rights reserved.