Thread: Memory layout of c program

  1. #1
    Registered User
    Join Date
    Oct 2013
    Posts
    2

    Memory layout of c program

    With respect to memory layout for a C program to run, is the stack memory is responsible for calling the main function?

  2. #2
    11DE784A SirPrattlepod's Avatar
    Join Date
    Aug 2013
    Posts
    485
    See section 5.1.2.2.1 Program startup of C99 standard

  3. #3
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    The stack has nothing to do with it. As for section 5.1.2.2.1 of the C99 draft standard, it can be found here

    In essence, the system must behave as if the operating system called main to start the program. In practice, the OS usually calls another function which performs startup tasks and then calls main.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  4. #4
    Registered User
    Join Date
    Oct 2013
    Posts
    2
    Thanks for the reference.
    I understand that the main function call is handled by the OS execution env and the information regarding this call is stored in the stack memory.Am I right?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 14
    Last Post: 10-12-2012, 02:39 AM
  2. memory layout??
    By ungainly_one in forum C Programming
    Replies: 14
    Last Post: 11-14-2010, 10:12 AM
  3. memory layout problem
    By iamnew in forum C Programming
    Replies: 5
    Last Post: 06-05-2010, 08:48 AM
  4. Memory Layout
    By chris.r in forum C Programming
    Replies: 5
    Last Post: 04-18-2010, 02:41 PM
  5. memory layout and declaration
    By cbastard in forum C Programming
    Replies: 6
    Last Post: 09-13-2005, 12:24 PM