C Call Stack Relive

Source: Internet
Author: User

C stack address is from the high address constantly forget the low address expansion, the first function called the highest stack address, after the address is called Low:

A-"h" These addresses indicate a basic invocation relationship, AB is a function entry, and a CD is a variable within a function.

The caller precedes the high address, and the caller is at the low address.

The order of the parameters is, at the left of the argument in the low address, the right side of the parameter in the high address, so if the entry is the function of the return value form, then the call order should be first and left.

The declaration of a variable in a function is a high-level address declared first, followed by the argument at the low address.

Today to see colleagues sent a crash problem location when you feel like Forget, review, hereby record ~

The function code is as follows:

#include <iostream>using namespacestd;#definePrint_addr (a) {cout << #a << ":" << (unsigned int) &a << ";" << "Val:" << a <&lt ; Endl }voidSTACKFOUNCTINB (unsignedintUnparame, unsignedintUNPARAMF) {unsignedintUNPARAMG =7; unsignedintUNPARAMH =8;    PRINT_ADDR (Unparame);    PRINT_ADDR (UNPARAMF);    PRINT_ADDR (UNPARAMG); PRINT_ADDR (UNPARAMH);}voidStackfounctina (unsignedintUnparama, unsignedintunparamb) {unsignedintUNPARAMC =3; unsignedintUNPARAMD =4;    PRINT_ADDR (Unparama);    PRINT_ADDR (UNPARAMB);    PRINT_ADDR (UNPARAMC);    PRINT_ADDR (UNPARAMD); STACKFOUNCTINB (5,6 );}intMain () {unsignedintUnparammaina =Ten; unsignedintUNPARAMMAINB = One;    PRINT_ADDR (Unparammaina);    PRINT_ADDR (UNPARAMMAINB); Stackfounctina (1,2 ); return 0;}

C Call Stack Relive

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.