Need help with pointer question!!

Write a function that reverses the values of an array of floating-point data:
void reverse(double* a, int size)
In the function, use two pointer variables, not integer indexes, to traverse the array
elements.
start with this...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
float *ptr1;
float *ptr2;

ptr1 = a[0];
ptr2 = a[size - 1];

for(int i = 0; i < (size-1)/2; i++){
{
temp = ptr1;
ptr1 = ptr2;
ptr2 = temp;
ptr1++;
ptr2--;
}


something like that... not sure if its close but something along those lines
Last edited on
Topic archived. No new replies allowed.