home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_08_07
/
8n07091a
< prev
next >
Wrap
Text File
|
1990-06-19
|
983b
|
57 lines
main()
{
int i = 0XFFFF;
double d = 123456789.123456789;
char c;
/* This is okay, cast does nothing */
(char) c = 'A';
printf("\n I is %x", i);
(char) i = 'A';
printf("\n I is %x", i);
*(&(char)i + 1) = 'B';
printf("\n I is %x", i);
/* Show it the "right" way */
i = 0XFFFF;
printf("\n I is %x", i);
*((char *) &i + 1) = 'B';
printf("\n I is %x", i);
/* Now try it with a double */
printf("\n d is %lf", d);
(int) d = 'C';
printf("\n d is %lf", d);
/* This causes a compiler error -- */
/* This was removed so that the listing could be
produced */
(double) i = 'A';
}
Results:
I is ffff
I is ff41
I is 4241
I is ffff
I is 42ff
d is 123456789.123457
d is 123456789.123048