Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!hao!hplabs!sri-unix!@BRL-AOS.ARPA: From: @BRL-AOS.ARPA: Newsgroups: net.unix-wizards Subject: Re: Function with variable number of args Message-ID: <1282@sri-arpa.UUCP> Date: Mon, 25-Jun-84 23:03:41 EDT Article-I.D.: sri-arpa.1282 Posted: Mon Jun 25 23:03:41 1984 Date-Received: Sat, 30-Jun-84 01:38:02 EDT Lines: 24 From: Eric Benson <@BRL-AOS.ARPA:> In BCPL, all values are the same size, one "word." If a function is called with six arguments, they are contained in exactly six words. In C, some data types (e.g, doubles on VAXen, longs, floats and doubles on 11's) do not fit in one word. _doprnt has to increment its argument pointer by different amounts depending on the data type, which it determines by looking at the corresponding printf format. Notice what happens when you try printf("This is not an integer: %d, but these are floats: %f, %f and %f", 1.0, 2.0, 3.0, 4.0); You expect garbage to be printed in the first case, but you may be surprised to see garbage in the other cases as well. That happens because you have made the argument pointer point into the middle of 1.0. The next thing to be printed is not 2.0, but part of 1.0 and part of 2.0. It is for this reason, among others, that it is difficult to define a portable facility for handling a variable number of arguments. -- Eric -------