home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C Programming Starter Kit 2.0
/
SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso
/
tyc
/
list11_6.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-16
|
817b
|
30 lines
/* Example of using more than one union member at a time */
#include <stdio.h>
main()
{
union shared_tag {
char c;
int i;
long l;
float f;
double d;
} shared;
shared.c = '$';
printf("\nchar c = %c", shared.c);
printf("\nint i = %d", shared.i);
printf("\nlong l = %ld", shared.l);
printf("\nfloat f = %f", shared.f);
printf("\ndouble d = %f", shared.d);
shared.d = 123456789.8765;
printf("\n\nchar c = %c", shared.c);
printf("\nint i = %d", shared.i);
printf("\nlong l = %ld", shared.l);
printf("\nfloat f = %f", shared.f);
printf("\ndouble d = %f", shared.d);
}