The path of C pointer programming and the path of pointer Programming
This time we sorted out the function pointers and pointer functions.
This is a pointer call:
Code:
# Include <iostream>
# Include <cstdio>
Using namespace std;
Typedef unsigned char unit8_t;
Extern void swapdata (unit8_t dat_x, unit8_t dat_y );
Int main ()
{
Unit8_t x, y;
Scanf ("% d", & x, & y );
Printf ("Before change: x = % d, y = % d \ n", x, y );
Swapdata (x, y );
Printf ("after exchange: x = % d, y = % d \ n", x, y );
Return 0;
}
Void swapdata (unit8_t dat_x, unit8_t dat_y)
{
Unit8_t temp;
Temp = dat_y;
Dat_y = dat_x;
Dat_x = temp;
}
Next:
// Common parameters and pointer Parameters
// Define a pointer to a function
// Int (* P_output) is a function pointer.
// The return value is int type (* p_output) and is a pointer function.
# Include <iostream>
# Include <cstdio>
Using namespace std;
Void output ();
Void output ()
{
Cout <"LongMai is OK \ n" <endl;
}
Int main ()
{
Void (* p_output )();
P_output = output;
(* P_output )();
Return 0;
}
// Pointer Function
// The return value indicates that the pointer function is a pointer function.
// Int * p_fun (). This is a pointer function.
// Int (* p_fun (). This is the function pointer.
# Include <iostream>
# Include <cstdio>
Int * p_func ()
{
/*
*
**/
}
Int main ()
{
Int * p_funx ();
/****
*
*
****/
Return 0;
}