> -----Original Message-----
> From: dev...@li...=20
> [mailto:dev...@li...] On Behalf=20
> Of Andr? Macario Barros
> Sent: Tuesday, August 26, 2003 6:30 AM
> To: Dev-Cpp-Users
> Subject: [Dev-C++] %d and %ld printf output formats
>=20
>=20
> Dear users,
>=20
> Please consider the following C code:
>=20
> ...
> int var=3D65534;
>=20
> 1- printf("%d\n", var);
> 2- var++;
> 3- printf("%d\n", var);
> 4- var*=3D1000;
> 5- printf("%d\n", var);
> 6- var++;
> 7- printf("%d\n", var);
> ...
>=20
> I though that above 65535 (or 32767!) I would need the %ld=20
> output format,
> but It wasn=B4t necessary.
%d specifies that the argument is of type int. The limits of type int =
are
implementation-specific. In this case you printf() the value of var =
which is
an int, so %ld shouldn't be used.
> Even in lines 5 and 7. I though the 2 complement would start=20
> presenting the
> complement values.
?
>=20
> Does anybody can explain what happend?
What was expected to happen. You printf() the stored values in decimal
format.
Ioannis Vranos
=20
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL 1: http://run.to/noicys
* Alternative URL 2: http://www.noicys.cjb.net
|