From owner-freebsd-hackers Fri Feb 26 13: 1: 9 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from mailhub.psn.ie (mailhub.psn.ie [194.106.150.254]) by hub.freebsd.org (Postfix) with ESMTP id 09F0714FFC for ; Fri, 26 Feb 1999 13:01:06 -0800 (PST) (envelope-from ad@psn.ie) Received: from gromit.psn.ie ([194.106.150.251] helo=psn.ie) by mailhub.psn.ie with esmtp (Exim 2.12 #3) id 10GUJI-0004Zi-00; Fri, 26 Feb 1999 20:56:36 +0000 Message-ID: <36D70AC8.A862B8C0@psn.ie> Date: Fri, 26 Feb 1999 20:57:44 +0000 From: Andy Doran Organization: Pobalscoil Neasain X-Mailer: Mozilla 4.5 [en] (Win95; I) X-Accept-Language: en MIME-Version: 1.0 To: "Alton, Matthew" Cc: "'Hackers@FreeBSD.ORG'" , "Ladendorf, Matt" Subject: Re: printf wierdness References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG printf() is treating the %llu type as an unsigned long (%lu), so it's taking the value for %s from the second 32-bits in 'foo'. Check the printf(3) manpage. Andy. "Alton, Matthew" wrote: > > Why is this happening? > > $ vi foo.c > > #include > > int > main(void) > { > unsigned long long int foo = 0; > char *bar = "Hidely Ho!"; > > (void)printf("%llu %s\n", foo, bar); > (void)printf("%s %llu\n", bar, foo); > > return 0; > } > > ~ > ~ > ~ > ~ > ~ > ~ > ~ > ~ > ~ > foo.c: 14 lines, 196 characters. > $ make foo > cc foo.c -o foo > $ ./foo > 0 (null) > Hidely Ho! 0 > $ > > Matthew Alton > Computer Services - UNIX Systems Administration > (314)632-6644 matthew.alton@anheuser-busch.com > alton@plantnet.com > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message