Returns the pointer-type data as an address
For example: int * (int x,int y), A is the function name, call it to get an in * pointer, that is, the address of the shaping data, X and Y is the formal parameter of function A is an integer
Defines the general shape of a function that returns a pointer:
Type name * Function name (parameter list);
Here's an example to get a preliminary look at
#include <stdio.h>intMain () {floatscore[][4]={{ -, -, the, -},{ About, the, the, the},{ the, +, -, the}}; float*search (float(*pointer) [4],intn);//function Declaration float*p; inti,k; printf ("Enter the number of student:"); scanf ("%d",&k); printf ("The scores of no.%d are:\n", K); P=search (SCORE,K);//call the search function to return the address of score[k][0] for(i=0;i<4; i++) printf ("%5.2f\t", * (p+i)); printf ("\ n"); return 0;}float*search (float(*pointer) [4],intN//formal parameter pointer is a one-dimensional array pointer variable that contains 4 elements{ float*pt; PT=* (pointer+N); return(PT);}
#include <stdio.h>intMain () {floatscore[][4]={{ -, -, the, -},{ About, the, the, the},{ the, +, -, the}}; float*search (float(*pointer) [4]);//function Declaration float*p; inti,j; for(i=0;i<3; i++)//Cycle three times{p=search (score+i); if(p==* (Score+i))//returns NULL if the return value is the address of score[i][0]{printf ("no.%d Score:", i); for(j=0;j<4; j + +) printf ("%5.2f", * (P+J));//value of output CORE[I][0]~SCORE[I][3]printf"\ n"); } } return 0;}float*search (float(*pointer) [4])//formal parameter pointer is a one-dimensional array pointer variable that contains 4 elements{ intI=0; float*pt; PT=NULL; for(;i<4; i++) if(* (*pointer+i) < -) Pt=*pointer;//If you fail the course, point pt to Score[i][0] return(PT);}
Functions that return pointer values