From owner-freebsd-bugs Mon Mar 19 2:52:55 2001 Delivered-To: freebsd-bugs@freebsd.org Received: from ringworld.nanolink.com (ringworld.nanolink.com [195.24.48.13]) by hub.freebsd.org (Postfix) with SMTP id 4DE6A37B718 for ; Mon, 19 Mar 2001 02:52:49 -0800 (PST) (envelope-from roam@orbitel.bg) Received: (qmail 1260 invoked by uid 1000); 19 Mar 2001 10:28:01 -0000 Date: Mon, 19 Mar 2001 12:28:01 +0200 From: Peter Pentchev To: G Hasse Cc: dwmalone@FreeBSD.org, freebsd-bugs@FreeBSD.org Subject: Re: misc/25904: Error in the printf-function. Message-ID: <20010319122801.D515@ringworld.oblivion.bg> Mail-Followup-To: G Hasse , dwmalone@FreeBSD.org, freebsd-bugs@FreeBSD.org References: <200103191005.f2JA51r98657@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from gh@raditex.se on Mon, Mar 19, 2001 at 11:15:43AM +0100 Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Mon, Mar 19, 2001 at 11:15:43AM +0100, G Hasse wrote: > On Mon, 19 Mar 2001 dwmalone@FreeBSD.org wrote: > > > Synopsis: Error in the printf-function. > > > > State-Changed-From-To: open->closed > > State-Changed-By: dwmalone > > State-Changed-When: Mon Mar 19 02:04:13 PST 2001 > > State-Changed-Why: > > Seems to be due to misues of printf. > > In Linux printf I get this printout... > > Var is 2.256102 /* an address printed as float. Stupid! but the > Value is 2.400000 way to print an float adress? */ > Var is 2.256102 > Value is 4 > Var is 4 > > So way is the conversion of an address in FreeBSD 0? To print a pointer, you use printf("%p", ptr). To print a float variable, you use printf("%f", var). To print a float value, which hangs at the end of a pointer to a float, you must first dereference the pointer, and pass the value to printf() as a simple float: float v, *p; v = 2.5; p = &v; printf("v is %f, p is %p, *p is %f\n", v, p, *p); G'luck, Peter -- If wishes were fishes, the antecedent of this conditional would be true. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message