Path: utzoo!utgpu!attcan!uunet!husc6!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: Passing types to a subroutine Message-ID: <8853@smoke.BRL.MIL> Date: 10 Nov 88 16:59:12 GMT References: <14457@mimsy.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 22 In article <14457@mimsy.UUCP> sjr@mimsy.UUCP (Stephen J. Roznowski) writes: > float a[100]; > subroutine(...., a[100], ...); > double a[100]; > subroutine(...., a[100], ...); >subroutine(....,array,....) >[???] *array; >How do you pass the knowledge of the array type to the >subroutine? You don't. Types are dealt with at compile time, not run time. It is in fact possible for a pointer-to-float to be passed differently than a pointer-to-double. If you REALLY have to do this, consider casting the arguments (which should be "a", not "a[100]") to type pointer-to-void or pointer-to-char, and add another parameter to the subroutine that can be used to indicate how to "un-cast" the funny parameter. The code for this won't be clean..