I have this problem to work through and I wanted some clarification::

Rewrite the following function using pointer arithmmetic instead of array subscripting.

[CODE]

int total_array (int b[], int q)

{

int j, total = 0;

for (j = 0; j < q; j++)

total += b[j];

return total;

}

[\CODE]

Would this be rewritten as follows??

[CODE]

int total_array (int b[], in q)

{

int *ptr;

int *total =0;

for (ptr = b; ptr < b + N; ptr++)

total += *ptr;

return total;

}

[\CODE]

N is the total elements of array

Not sure if I get pointer arithmetic or it's true purpose

Could someone give me a better explanation than my textbook???