Date: Mon, 19 Mar 2001 11:16:47 -0500 (EST) From: Garrett Wollman <wollman@khavrinen.lcs.mit.edu> To: Peter Pentchev <roam@orbitel.bg> Cc: G Hasse <gh@raditex.se>, dwmalone@FreeBSD.ORG, freebsd-bugs@FreeBSD.ORG Subject: Re: misc/25904: Error in the printf-function. Message-ID: <200103191616.LAA93612@khavrinen.lcs.mit.edu> In-Reply-To: <20010319122801.D515@ringworld.oblivion.bg> References: <200103191005.f2JA51r98657@freefall.freebsd.org> <Pine.BSF.4.21.0103191113530.12867-100000@gandalf.sickla.raditex.se> <20010319122801.D515@ringworld.oblivion.bg>
next in thread | previous in thread | raw e-mail | index | archive | help
<<On Mon, 19 Mar 2001 12:28:01 +0200, Peter Pentchev <roam@orbitel.bg> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200103191616.LAA93612>