首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

怎么用数组指针传值

2013-11-21 
如何用数组指针传值我想将数组a中的值传给数组b,但是实现不了,为什么啊?#include stdio.hfun(double*p){

如何用数组指针传值
我想将数组a中的值传给数组b,但是实现不了,为什么啊?
#include <stdio.h>
fun(double*p)
{

double a[10]={0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0};
p=a;
return 0;
}

int main()
{
double b[10]={0.0};
fun(b);
printf("%f",b[5]);
return 0;
}
结果为0.0000
[解决办法]


include <stdio.h>
fun(double*p)
{

double a[10]={0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0};
//p=a; //这里只是地址操作而已
memcpy((void*)p, (void*)a, sizeof(double) * 10); //用这个试试
return 0;
}

热点排行