You need to know exactly what the C ++ function expects.
In C (and C ++), all of these function signatures are exactly the same for all goals and objectives:
void foo( float *x , float *y ) ; void foo( float *x , float y[] ) ; void foo( float x[] , float *y ) ; void foo( float x[] , float y[] ) ;
They all take 2 arguments, each of which contains a pointer to (containing the address) a variable of type float . And all these expressions are exactly identical in C / C ++:
float x[] ; float *y ; float r1 = *(x+37) ; // all evaluate to the zero-relative float r2 = x[37] ; // 37th element of the array. float r3 = *(y+37) ; float r4 = y[37] ;
- The expression
*x says: "Retrieve the float (4 bytes) located at the address contained in x . - The expression
*(x+n) , where n is an integer value, says: "Take the address contained in x and add the offset in bytes obtained by the expression sizeof(float) * n . Extract the float value at the resulting address. - The array expression
x[n] is exactly equivalent to the pointer expression *(x+n) .
And since arrays in C / C ++ do not have associated metadata describing their size, you need to know exactly what the function expects.
Typically, one passes a pointer (call by reference) to allow the caller to de-link to a point and set a value for you - the equivalent of the C # ref and out keywords:
float x ; float y ; Foo( ref x , ref y ) ; // the callee MAY, but is not REQUIRED to set a value before returning to the caller. Bar( out x , out y ) ; // the callee MUST set a value before returning to the caller.
The idiom that your function uses is always used to search for an array, although usually the size also goes through:
void foo( float *array , int array_length ) ;
Although this is not unusual, if the function expects the array to be a list of non-zero numeric values, it will be something like a C-style, NUL-terminated string. Given a function signature, for example:
float compute_mean( float *Xs ) ;
It is not unusual to expect it to be called like this:
float Xs[] = { 3.0 , 2.5 , 9.8 , 7,5 , 0 , } ; float mean = compute_mean( Xs ) ;
and the definition should look something like this:
float compute_mean( float *Xs ) { float n = 0.0 ; float sum = 0.0 ; float mean ; while ( *p ) { ++n ; sum += *p++ ; } mean = n > 0 ? sum / n : 0.0 ; return mean ; }
So you need to know the semantics of the method you are calling.
Hope this helps.