函数调用问题
#include <stdio.h>#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define LEN 20
void transform(double *source, double *target, int n, double (*fp)(double));
int main(void)
{
double source[LEN];//源数组
double target[LEN];//目标数组
double num;
transform(source, target, LEN, sin(num)); //这里提示 错误
return 0;
}
void transform(double sou[LEN], double tar[LEN], int LEN, double sin(double num))
{
int i;
srand((unsigned)time(NULL));
for(i = 0; i < LEN; i++) //为源数组赋值
{
sou[i] = rand() % 100 +1;
printf("%.2f ", sou[i]);
}
for(i = 0; i < LEN; i++) //把源数组值求正玄值赋值给目标数组
{
tar[i] = sin(sou[i]);
printf("%.2f ", tar[i]);
}
}
[Error] cannot convert 'double' to 'double (*)(double)' for argument '4' to 'void transform(double*, double*, int, double (*)(double))'