can we initialize all the members of union?

Answer Posted / vadivelt

Since Union follows the memory sharing concept, it is not
possible to initialise all union varibles at a time.

ie.,

union name
{
int a;
char b;
}c = {10, 'a'};

is not possible.

But it is possible to initialise one value at a time.

ie.,

union name
{
int a;
char b;
}c = {10};

or

union name
{
int a;
char b;
}c = {'a'};

Is This Answer Correct ?    0 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I rethow can I return a sequence of random numbers which dont repeat at all?

700


What is the newline escape sequence?

578


What is assert and when would I use it?

573


What does the characters “r” and “w” mean when writing programs that will make use of files?

848


Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10

15043






What's the difference between constant char *p and char * constant p?

649


using for loop sum 2 number of any 4 digit number in c language

1725


What are two dimensional arrays alternatively called as?

653


What are the different properties of variable number of arguments?

657


Explain the properties of union.

607


What is structure in c explain with example?

628


When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?

797


Describe the header file and its usage in c programming?

614


What is meant by type casting?

618


What is structure data type in c?

562