I get the following errors:
expected 'float **' but argument is of type 'float (*)[3]'
and expected 'float * (*)[3]' but argument is of type 'float (*)[3][3]'
when I run the following code
#include <stdio.h>
#include <math.h>
// Should be determined from datasheet
#define SD 0.1
float verticalSlope(int *size, float *velocity[*size],float *position[*size][3])
{
if (*size<2)
{
return 0;
}
int teller=0;
while (fabsf(*velocity[*size-1-teller])<SD)
{
teller=teller+1;
}
float horizontal=sqrtf(pow(*position[*size-1-teller][0]-*position[*size-2-teller][0],2)+pow(*position[*size-1-teller][1]-*position[*size-2-teller][1],2));
float vertical=*position[*size-1-teller][2]-*position[*size-2-teller][2];
float slope=vertical/horizontal;
return slope;
}
int main()
{
printf("Hello, this is a little script that illustrates the working of the function verticalSlope. (0=default value) \n");
int lengte=3;
float snelheid[3]={1.0, 1.0, 1.0};
float positie[3][3]={{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{3.0, 4.0, 5.0}};
printf("The return for verticalSlope(3,{1 1 1},{{0 0 0},{0 0 0},{3 4 5}) is: %f \n", verticalSlope(&lengte,&snelheid,&positie));
int lengte2=2;
float snelheid2[3]={0.0, 0.0, 0.0};
float positie2[3][3]={{1.0, 2.0, 1.0},{1.0, 2.0, 1.0},{1.0, 2.0, 1.0}};
printf("The return for verticalSlope({0 0 0},{{1 2 1}{ 1 2 1}{1 2 1})) is: %f \n", verticalSlope(&lengte2,&snelheid2,&positie2));
return 0;
}
The error is in the main when I try to call the function verticalSlope
. I have been thinking about the datatypes that I give in but my ideas about them do not match the error. Could somebody hint at me in the right direction?