I have this code but is not working , it keep giving me the following errors :
[Error] cannot convert 'float' to 'float*' for argument '1' to 'void zeroCrossing(float*, float*, int)'
[Error] cannot convert 'float*' to 'float' for argument '1' to 'bool getSign(float)'
[Error] cannot convert 'float*' to 'float' for argument '1' to 'bool getSign(float)'
[Error] invalid conversion from 'int' to 'float*' [-fpermissive]
#include <iostream>
#include <cstring>
using namespace std;
void zeroCrossing(float *data, float *zerCross, int nx);
bool getSign(float data);
float array[9] = {1,2,3,0,-1,-2,-3,0,1};
float *p = array;
float f1[9];
float *p2 = f1;
int bx= 2 ;
int main() {
zeroCrossing(*p,*p2,bx);
return 0 ;
}
/* zero crossing function */
/* data = input array */
/* zerCross = output zero crossing array */
void zeroCrossing(float *data[], float *zerCross[], int nx)
{
int i;
bool sign1, sign2;
memset(zerCross, 0, nx*sizeof(float));//copies the 0 to the first characters of the string
//pointed to, by argument
for(i=0; i<nx-1; i++) /* loop over data */
{
sign1 = getSign(data[i]);
sign2 = getSign(data[i+1]);
if(sign1!=sign2) /* set zero crossing location */
zerCross[i+1] = 1;
}
}
/* get sign of number */
bool getSign(float data)
{
if(data>0) /* positif data */
return (1);
else /* negatif data */
return (0);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…