-2

Global variables are stored in data, dynamically allocated variables are stored in heap, etc. Where are functions (such as main, other functions in main.c, printf, etc) stored? Is it in the code segment?

JP1992
  • 49
  • 6

1 Answers1

1

This is not a C or C++ question. Neither of those ISO standards mandate anything like how different things are allocated to memory segments.

In fact, the whole idea of segments is irrelevant to the standards since they dictate the behaviour of a C or C++ "virtual machine" - they tend to dictate behaviour rather than how the behaviour is achieved.

However, if you're in an implementation that has a code segment, that's the most likely place where code would be stored :-)

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953