C Language review: Memory model 2

Source: Internet
Author: User

Function Call Model Fundamentals

It's actually a constant jump from one memory to another.

function call Variable pass analysis
    1. A main program has n functions, the C + + compiler will build several heap areas? How many stack areas are there?

      A: A program has only one heap area and one stack area.

    2. When a function is nested, how does the C + + compiler manage the life cycle of a variable when the argument address is passed to the parameter?

      The upper-level variable can be used in the next-level invocation, and the parent variable still exists after the parameter is passed. The subordinate variable cannot be called in the ancestor, except for the variable that is opened in the heap area. The life cycle of the upper subordinate variables is mainly due to the characteristics of the stack: first in and out, then in first out

Analysis: function A, call function B, the variable passed by the parameter (memory space can be used?). )

Tip: Establishing the correct program to run the memory layout is the key to learning C.

Attention to the wild hands;

The growth direction of the stack area;

C Language review: Memory model 2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.