1. Pass value parameters (non-pointer parameters ):
# Include <stdio. h> int Inc (int x); int main (void) {int num = 1; printf ("% d \ n", Inc (Num )); /* 2 */printf ("% d \ n", num);/* 1; num does not change. When used as a function parameter, it only copies the past */getchar (); return 0;} int Inc (int x) {x ++; return X ;}
2. Address Transfer: the parameter is a pointer and the parameter is an address
# Include <stdio. h> int Inc (int * P); int main (void) {int num = 1; printf ("% d \ n", Inc (& num )); /* 2 */printf ("% d \ n", num);/* 2; num modified */getchar (); Return 0 ;} int Inc (int * P) {* P = * p + 1;/* changed the value through the address */return * P ;}
3. Example of transferring an address but not modifying it:
# Include <stdio. h> int Inc (int * P); int main (void) {int num = 1; printf ("% d \ n", Inc (& num )); /* 2 */printf ("% d \ n", num);/* 1 * // although the function is a transfer address, the num here has not changed; because the following function does not assign a value to the pointer */getchar (); Return 0;} int Inc (int * P) {return * p + 1 ;}
4. participate in real parameters:
This is just a title that does not make much sense. For example, in the following example
X and Y are the form parameters of the sum function;
I and 22 are the real parameters of the sum function.
# Include <stdio. h> int sum (int x, int y); int main (void) {int I = 11; I = sum (I, 22 ); printf ("% d \ n", I); getchar (); Return 0 ;}int sum (INT X, int y) {return X + Y ;}