返回指针的函数

/*返回指针的函数 */
#include <stdio.h>
/*1.float(*pointer)[n]会把从参数中传递进来的数据进行分行,n个数为一行
 * 2.原数组score为4行3列(score标识)
 * 3.执行float(*pointer)[4]后数组score被重新划分为3行4列(用pointer标识)*/
#include <stdlib.h>
int main(void){
float score[][3]={60,70,80,90,56,89,67,88,34,78,90,66};
float *search();
float *p;
int i,k;
printf("enter the number of student:");
fflush(stdout);
scanf("%d",&k);
printf("the score of No.%d are:\n",k);
p=search(score,k);//通过二维数组入口地址传递到*search()中去,数组进行分组,4个为一组,并用p标记pointer
for(i=0;i<4;i++)
	printf("%5.2f\t",*(p+i));
printf("\n");
return 0;
}
float *search(float(*pointer)[4],int  n)
{
	float *pt;
	pt=*(pointer+n);//划分后的数组是一个多维数组
	return pt;
}

调试结果

enter the number of student:2
the score of No.2 are:
34.00	78.00	90.00	66.00	

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值