J
Jonathan Bartlett
Now I want to pass a pointer to an array of doubles, the size
Try this:
int func(double *array, int num_elements)
{
int i;
for(i = 0; i < num_elements; i++)
{
array = 1.0;
}
}
int main()
{
double array[100];
func(array, 100);
}
The single pointer will point to the first element of the array. You do
not need double indirection. You need to explicitly pass the size of
the array, as C does not keep that information store.
Jon
of the array must not be fixed though:
Try this:
int func(double *array, int num_elements)
{
int i;
for(i = 0; i < num_elements; i++)
{
array = 1.0;
}
}
int main()
{
double array[100];
func(array, 100);
}
The single pointer will point to the first element of the array. You do
not need double indirection. You need to explicitly pass the size of
the array, as C does not keep that information store.
Jon