Problem returning doubles from a function

Donal O'Mahony - OMAHONY@cs.tcd.ie omahony at csvax1.cs.tcd.ie
Thu Mar 23 04:37:02 AEST 1989


Can anone explain the problem with the following program (made up of
2 files).

::main.c
#include <stdio.h>
main()
{double a,b;

  a = 1.234;
  b = store_length(a);
  printf("b=%f\n",b);
}

::rt1.c
double store_length( double measurements)
{  measurements= 2;
  printf("Returning measurements=%f\n",measurements);
  return(measurements);
}

When these two programs are linked and run, they do not print 'b=2,'
as I would expect.  Why?
-- 
_______________________________________________________________________
Donal O'Mahony        omahony at cs.tcd.ie
Computer Science Dept., Trinity College, Dublin 2, Ireland
_______________________________________________________________________



More information about the Comp.lang.c mailing list