Mail Archives: djgpp/1997/01/13/06:11:23
> This is no cause for concern; a does not need to be reset! The reason
> is that it is passed in as a pointer to the function. Something like
> [I assume]:
>
> void test( double *a, int n )
> {
> /* decrementing a here has no effect on its value
> * in the calling program!!
> */
> a--; /* calling program cannot see this */
>
> /* HOWEVER changing the values that it points to
> * will be reflected in the calling program
> */
> a[1] = 16.0; /* calling program CAN see this change */
>
> }
>
No!, on return a[i] correspond now to a[i+1] before the function was called
(+whatever happened in the function). Because a (not *a) is a pointer,
--a changes that value! The code generated by f2c shoudl really use
a_new-- = a ; and then work with a_new rather than a. This causes that
a[i] still points to same element of a before _and_after the function
call !!
Leendert
- Raw text -