Passing types to a subroutine
Stephen J. Roznowski
sjr at mimsy.UUCP
Thu Nov 10 11:26:15 AEST 1988
I'm in the process of developing a piece of code that needs
to be portable across several different machines. What I
need to do is something of the following:
main()
{
...
float a[100];
subroutine(...., a[100], ...);
}
AND
main()
{
...
double a[100];
subroutine(...., a[100], ...);
}
and have the subroutine do the right thing with a[].
Eventually, the subroutine needs to so something like:
subroutine(....,array,....)
[???] *array;
{
unsign int i;
int scale;
float bias;
...
array[20] = (cast ???) i * scale + bias;
}
How do you pass the knowledge of the array type to the
subroutine? I need to be able to pass the knowledge
that the array a[] is either float or double (or for
that matter unsign int).
Any help will be greatly appreciated.
Stephen J. Roznowski sjr at mimsy.umd.edu
--
Stephen J. Roznowski sjr at mimsy.umd.edu
More information about the Comp.lang.c
mailing list