From owner-freebsd-bugs Mon Mar 19 8:16:53 2001 Delivered-To: freebsd-bugs@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id B471137B71A; Mon, 19 Mar 2001 08:16:50 -0800 (PST) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.9.3/8.9.3) id LAA93612; Mon, 19 Mar 2001 11:16:47 -0500 (EST) (envelope-from wollman) Date: Mon, 19 Mar 2001 11:16:47 -0500 (EST) From: Garrett Wollman Message-Id: <200103191616.LAA93612@khavrinen.lcs.mit.edu> To: Peter Pentchev Cc: G Hasse , dwmalone@FreeBSD.ORG, freebsd-bugs@FreeBSD.ORG Subject: Re: misc/25904: Error in the printf-function. In-Reply-To: <20010319122801.D515@ringworld.oblivion.bg> References: <200103191005.f2JA51r98657@freefall.freebsd.org> <20010319122801.D515@ringworld.oblivion.bg> Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org < said: Followups to comp.lang.c, please. > To print a pointer, you use printf("%p", ptr). Not quite. To print a pointer, use: printf("%p", (void *)ptr); > To print a float variable, you use printf("%f", var). Actually, there is no way to print a `float' using printf(); it is only possible to print `double' or `long double' values. This rarely makes a difference because unprototyped arguments to variadic functions always receive the default promotions, so floats are automatically converted to doubles before being passed to printf(). When using scanf(), on the other hand, it is possible to read a `float', since the arguments to scanf() are always passed by pointer; in scanf() formats, "%f" means `float' and to get double one must use "%lf". (`long double' is "%Lf".) -GAWollman To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message