D
Darklight
The program demonstrates the use of unions program taken from a book
why if i change one character in a program i get the following error
list10-6.c:14:20: warning: multi-character character constant
list10-6.c: In function `main':
list10-6.c:14: warning: overflow in implicit constant conversion
the program is below the offending line, is line 14 the character
is $ changed to £
/* LIST10-6..C EXAMPLE OF USING MORE THAN ONE UNION MEMBER AT A TIME */
#include<stdio.h>
int main(void)
{
union shared_tag{
char c;
int i;
long l;
float f;
double d;
}shared;
(14); 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("\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\n",shared.d);
return 0;
}
why if i change one character in a program i get the following error
list10-6.c:14:20: warning: multi-character character constant
list10-6.c: In function `main':
list10-6.c:14: warning: overflow in implicit constant conversion
the program is below the offending line, is line 14 the character
is $ changed to £
/* LIST10-6..C EXAMPLE OF USING MORE THAN ONE UNION MEMBER AT A TIME */
#include<stdio.h>
int main(void)
{
union shared_tag{
char c;
int i;
long l;
float f;
double d;
}shared;
(14); 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("\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\n",shared.d);
return 0;
}