#include <stdio.h>
// The function.
void Function( unsigned uIndex = 0, float *p_pArray[ ] = NULL )
{
if( p_pArray != NULL )
{
// Print the value at the specified index.
printf( "The value at %i is: %f.\n", uIndex, *p_pArray[ uIndex ] );
return;
}
}
// This is the array that will be passed.
float t_fArray[ 3 ] = { 5.0f, 2.3f, 8.9f };
int main( )
{
// Call the function.
Function( 0, &t_fArray ); // Error points to here.
return 0;
}
The error message: cannot convert 'float (*)[3]' to 'float**' for argument '2' to 'void Function(unsigned int, float**)'
Any idea on what's going on?
Note: I know that a return statement in a void function is pointless but I
use them as a personal preference.
I think it's this: in your function definition, you define Function() as taking an unsigned int and an array of pointer to floats, while on line 20 in main() you pass it the address of an array of floats.
#include <stdio.h>
// The function.
void Function( unsigned uIndex = 0, float p_pArray[ ] = NULL )
{
if( p_pArray != NULL )
{
// Print the value at the specified index.
printf( "The value at %i is: %f.\n", uIndex, p_pArray[ uIndex ] );
return;
}
}
// This is the array that will be passed.
float t_fArray[ 3 ] = { 5.0f, 2.3f, 8.9f };
int main( )
{
// Call the function.
Function( 0, t_fArray );
return 0;
}