这个程序提示了很多错误,依然不会改。
下面这个程序用到了函数指针,从源数组复制数据到目标数组。尽管提示了很多错误,我还是不会改。请帮忙。
#include "stdafx.h"
#include "stdio.h"
#include "math.h"
#define SIZE 10
void transform(*source, *target, int m, double(*p)(double));
double reciprocal(double x);
int main(void)
{
double source[SIZE], target[SIZE];
double x, y;
int i;
for(i=0; i<SIZE; i++)
{
source[i]= i+2;
}
transform(source, target, SIZE, reciprocal);
for(i=0; i<SIZE; i++)
{
printf("source[%d]=%lf -> target[%d]=%lf", i, source[i], i, target[i]);
if(i%5==0)
{
printf("\n");
}
}
return 0;
}
void transform(*source, *target, int m, double(*p)(double))
{
int i;
for(i=0; i<m; i++)
{
target[i] = (*p)source[i]+10;
}
}
double reciprocal(double x)
{
return 1/x;
}
void transform(*source, *target, int m, double(*p)(double));-》
void transform(double *source,double *target, int m, double(*p)(double))
target[i] = (*p)source[i]+10;-》
target[i] = (*p)(source[i])+10;