From owner-freebsd-questions Wed Jan 31 12:31:50 2001 Delivered-To: freebsd-questions@freebsd.org Received: from schuimpje.snt.utwente.nl (schuimpje.snt.utwente.nl [130.89.238.4]) by hub.freebsd.org (Postfix) with ESMTP id 2AD1E37B503 for ; Wed, 31 Jan 2001 12:31:31 -0800 (PST) Received: from phoenix (cal30b054.student.utwente.nl [130.89.229.25]) by schuimpje.snt.utwente.nl (Postfix) with SMTP id 9A3832905 for ; Wed, 31 Jan 2001 21:31:29 +0100 (CET) From: "Theo van Klaveren" To: Subject: Printf question Date: Wed, 31 Jan 2001 21:31:30 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Importance: Normal Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hello, I have a small(?) question about printf. If I have a struct with two 64-bit integers, defined as follows: typedef struct _smbfind_result { uint64_t r_id; uint64_t c_id; . . } smbfind_result; Now, let's take for example res->r_id=1 and res->c_id=255676. The following statement: printf ("result (result %ld, cid %ld)\n", res->r_id, res->c_id); Outputs "result (result 1, cid 0)", whereas the following: printf ("result (result %ld, cid %ld)\n", (long)res->r_id, (long)res->c_id); Outputs "result (result 1, cid 255676)", which is of course the correct answer. Why are the typecasts required? One would say the %ld would require printf() to format correctly, which it doesn't. Am I mixing types or something? Please CC me as I am not subscribed to -questions. Theo van Klaveren To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message