一、指针函数
1、定义
指针函数是返回指针的函数。 本质是函数,函数的返回值是指针。
语法:返回类型名称*函数名称(函数参数) ) ) ) ) ) ) ) )。
int*fun(intI,int j ); 2、范例
# include stdio.h # include assert.h # include string.h char * my strcpy (char * dest,const char *src ) assert ) ) 资产(src; char* tmp=dest; wile(*src!=' ' ) { *dest=*src; est; src; } *dest=' '; 返回时间; (}int main ) ) { char arr[20]; char *p='hello world!' ; memset(ARR、((0)、sizeof ) ARR ); char*result=mystrcpy(arr,p ); printf(%s(n )、result; 返回0; (二、函数指针
1、定义
函数指针是指向函数的指针。 首先,它是指向函数的指针。
语法格式:返回值的类型名称(*指针变量名称);函数参数) ) ) ) ) ) ) ) ) ) )。
int(*pfun ) ) int i,int j ) 2,例
#includestdio.hintmax(inta,int b ) if (ab ) ) { return a; }返回b; }int main () int (pfun ) ) int,int ); pfun=Max; intresult=(*pfun ) ) 2,3 ); //或int result=pfun (2,3 ); 打印(result=% dn ),result ); 返回0; }