Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Jan 2001 21:31:30 +0100
From:      "Theo van Klaveren" <t.vanklaveren@student.utwente.nl>
To:        <freebsd-questions@FreeBSD.org>
Subject:   Printf question
Message-ID:  <FHEHJFHKDJMJCKHHPLFGEEMFCCAA.t.vanklaveren@student.utwente.nl>

next in thread | raw e-mail | index | archive | help

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 <t.vanklaveren@student.utwente.nl>



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?FHEHJFHKDJMJCKHHPLFGEEMFCCAA.t.vanklaveren>