home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_08
/
1108113a
< prev
next >
Wrap
Text File
|
1993-06-08
|
420b
|
26 lines
/* bit2.c: Overlay an integer with a bit field structure */
#include <stdio.h>
struct date
{
unsigned day: 5;
unsigned mon: 4;
unsigned year: 7;
};
main()
{
unsigned int date, year = 92, mon = 8, day = 2;
struct date *dp = (struct date *) &date;
dp->mon = mon;
dp->day = day;
dp->year = year;
printf("%04X\n",date);
return 0;
}
/* OUTPUT:
* B902 */