How to write programs with pointers in C language
What this article shares with you is about how C language uses pointers to write programs. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it with the editor.
Topic requirement
Using the pointer to write a program, using the trapezoid method to calculate the definite integral in the following formula:
Reference code
First of all, explain the use of pointers: because the parameters passed are numeric, there is no need to use pointers to improve efficiency, so pointers are used here to point to functions.
Notice this statement in the calc () function:
Double (* pfunction) () = & function
That is, the process I have described has been realized.
The code is as follows:
# include # include double function (double x) {return (double) (pow (XMagol 3) + x double ha 2 + 1);} double calc (double a, double b) {double ha, hb, result=0; int i; double (* pfunction) () = & function; for (iS0; I