44th lesson The Secret of function parameters (i)

Source: Internet
Author: User

1. function Parameters

(1) Function parameters are essentially the same as local variables, allocating space on the stack

(2) The initial value of the function parameter is the argument value at the time of the function call

(3) The Order of evaluation of the function parameters depends on the implementation of the compiler (note: This refers to the order of evaluation in sequence, not into the stacking sequence !) )

Evaluation order of "instance analysis" function parameters

#include <stdio.h>intFuncintIintj) {printf ("i =%d, j =%d\n", I, J); return 0;}intf () {printf ("f () call...\n"); return 1;}intg () {printf ("g () call...\n"); return 2;}intMain () {intK =1; intA =0; Func (k++,k++);//gcc, VC, bcc:2,1printf ("k =%d\n", k);//3a= f () * g ();//* Both sides of the operand sequence is not fixed, VC, Gcc:f () is called First, then G ()    return 0;}

2. sequence points in the program

(1) There are certain order points in the program.

(2) The sequential point refers to the latest moment when the value of the variable is modified during execution

(3) When the program arrives at the order point , all previous operations must be completed .

3. Order points in C language

(1) At the end of each complete expression, the semicolon

(2) &&, | |,?:, after each parameter of the comma expression is evaluated

(3) after all argument evaluation is completed on function call (before entering function body)

Sequential points in the programming experiment program

4. Summary

(1) The parameters of the function allocate space on the stack

(2) The argument of the function does not have a fixed order of calculation

(3) sequential point is the latest time for variable modification in C language

44th lesson The Secret of function parameters (i)

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.