Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site watdcsu.UUCP Path: utzoo!watmath!watdcsu!haapanen From: haapanen@watdcsu.UUCP (Tom Haapanen [DCS]) Newsgroups: net.lang.c Subject: A stupid way to do variable # of arguments? Message-ID: <378@watdcsu.UUCP> Date: Wed, 22-Aug-84 14:11:03 EDT Article-I.D.: watdcsu.378 Posted: Wed Aug 22 14:11:03 1984 Date-Received: Thu, 23-Aug-84 01:07:39 EDT Organization: U of Waterloo, Ontario Lines: 43 <.^.> I missed a part of the discussion on variable arguments, so maybe my idea isn't new. Even more likely it's awkward and maybe even impossible. However, here goes: - Specify a reserved word, maybe `varargs'. - When you wish to call a variable argument function, do something like: int i, j; float x, y; long l; ... foo(varargs, i, x, l, y, ..) - When you declare foo, do: foo(argp, argv) char *argp; char *argv[]; { ... - OK, so what will happen here is that the 'varargs' tells 'C' that this is a special case. What 'C' will do upon calling the function is set up an array of pointers to the parameters (in argv), as well as a descriptor string (in argp). The argp string could be of printf/scanf type, or it could just be a string of single character descriptors (f=float, d=double, i=int, l=long, c=char). Naturally, the called function would stilll have to do some processing to pull out the parameters, but it would be easier than it is now. You'd also have to typecast each element of the pointer array, I guess. Can anybody tell me (preferably by mail) why this would never work (besides being clumsy)? Thanks. Tom Haapanen University of Waterloo {allegra,decvax,ihnp4}!watmath!watdcsu!haapanen ----- I never claimed I understood anything...